How Do I Import the Redis Python Module? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?How can I safely create a nested directory in Python?How to import a module given its name?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?Importing files from different folder

number sequence puzzle deep six

Can the DM override racial traits?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

What's the point in a preamp?

Is 'stolen' appropriate word?

Keeping a retro style to sci-fi spaceships?

Single author papers against my advisor's will?

Why can't devices on different VLANs, but on the same subnet, communicate?

Deal with toxic manager when you can't quit

Student Loan from years ago pops up and is taking my salary

Did the new image of black hole confirm the general theory of relativity?

Hello, Goodbye, Adios, Aloha

Do warforged have souls?

Could an empire control the whole planet with today's comunication methods?

Would an alien lifeform be able to achieve space travel if lacking in vision?

Why doesn't shell automatically fix "useless use of cat"?

Variable with quotation marks "$()"

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

Do working physicists consider Newtonian mechanics to be "falsified"?

How to determine omitted units in a publication

Solving overdetermined system by QR decomposition

How did passengers keep warm on sail ships?

Why are PDP-7-style microprogrammed instructions out of vogue?

Does Parliament hold absolute power in the UK?



How Do I Import the Redis Python Module?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?How can I safely create a nested directory in Python?How to import a module given its name?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?Importing files from different folder



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I ran my project and received the following error:



File "/home/nguyentv/schoollink/web/views/apis.py", line 10, in <module>
from util.redis.redis_client import Redis
ImportError: No module named util.redis.redis_client


How do I properly import this library?










share|improve this question
























  • Is this some existing code you are trying to run or are you writing this own your own?

    – Karan Razdan
    Mar 22 at 5:46











  • This is the current code when I try to run the project.

    – nguyên trần
    Mar 22 at 6:00

















0















I ran my project and received the following error:



File "/home/nguyentv/schoollink/web/views/apis.py", line 10, in <module>
from util.redis.redis_client import Redis
ImportError: No module named util.redis.redis_client


How do I properly import this library?










share|improve this question
























  • Is this some existing code you are trying to run or are you writing this own your own?

    – Karan Razdan
    Mar 22 at 5:46











  • This is the current code when I try to run the project.

    – nguyên trần
    Mar 22 at 6:00













0












0








0








I ran my project and received the following error:



File "/home/nguyentv/schoollink/web/views/apis.py", line 10, in <module>
from util.redis.redis_client import Redis
ImportError: No module named util.redis.redis_client


How do I properly import this library?










share|improve this question
















I ran my project and received the following error:



File "/home/nguyentv/schoollink/web/views/apis.py", line 10, in <module>
from util.redis.redis_client import Redis
ImportError: No module named util.redis.redis_client


How do I properly import this library?







python django






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 6:26









Ryan Zacharias

92




92










asked Mar 22 at 5:31









nguyên trầnnguyên trần

1




1












  • Is this some existing code you are trying to run or are you writing this own your own?

    – Karan Razdan
    Mar 22 at 5:46











  • This is the current code when I try to run the project.

    – nguyên trần
    Mar 22 at 6:00

















  • Is this some existing code you are trying to run or are you writing this own your own?

    – Karan Razdan
    Mar 22 at 5:46











  • This is the current code when I try to run the project.

    – nguyên trần
    Mar 22 at 6:00
















Is this some existing code you are trying to run or are you writing this own your own?

– Karan Razdan
Mar 22 at 5:46





Is this some existing code you are trying to run or are you writing this own your own?

– Karan Razdan
Mar 22 at 5:46













This is the current code when I try to run the project.

– nguyên trần
Mar 22 at 6:00





This is the current code when I try to run the project.

– nguyên trần
Mar 22 at 6:00












2 Answers
2






active

oldest

votes


















0














The Module Search Path




When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:



  • the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

  • the installation-dependent default.

After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.




Basically, the interpreter is going to perform a lookup in your current working directory, then it will search through the system defined library directories.



The issue you are facing could be that your code is looking for a module that does not exist, you are calling the script from an incorrect directory, or the sys.path is setup incorrectly.



I could help more if you showed how you instantiated the interpreter, pwd output, and tree output.






share|improve this answer






























    0














    You are trying to import Redis from a package named util. Unless this package is part of your application, it does not exist.



    According to python-redis' documentation, here is how to import it:



    import redis
    # then use redis.Redis(...)


    or, equivalently:



    from redis import Redis
    # then use Redis(...)





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293423%2fhow-do-i-import-the-redis-python-module%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      The Module Search Path




      When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:



      • the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

      • the installation-dependent default.

      After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.




      Basically, the interpreter is going to perform a lookup in your current working directory, then it will search through the system defined library directories.



      The issue you are facing could be that your code is looking for a module that does not exist, you are calling the script from an incorrect directory, or the sys.path is setup incorrectly.



      I could help more if you showed how you instantiated the interpreter, pwd output, and tree output.






      share|improve this answer



























        0














        The Module Search Path




        When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:



        • the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

        • the installation-dependent default.

        After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.




        Basically, the interpreter is going to perform a lookup in your current working directory, then it will search through the system defined library directories.



        The issue you are facing could be that your code is looking for a module that does not exist, you are calling the script from an incorrect directory, or the sys.path is setup incorrectly.



        I could help more if you showed how you instantiated the interpreter, pwd output, and tree output.






        share|improve this answer

























          0












          0








          0







          The Module Search Path




          When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:



          • the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

          • the installation-dependent default.

          After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.




          Basically, the interpreter is going to perform a lookup in your current working directory, then it will search through the system defined library directories.



          The issue you are facing could be that your code is looking for a module that does not exist, you are calling the script from an incorrect directory, or the sys.path is setup incorrectly.



          I could help more if you showed how you instantiated the interpreter, pwd output, and tree output.






          share|improve this answer













          The Module Search Path




          When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:



          • the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).

          • the installation-dependent default.

          After initialization, Python programs can modify sys.path. The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path. This means that scripts in that directory will be loaded instead of modules of the same name in the library directory. This is an error unless the replacement is intended. See section Standard Modules for more information.




          Basically, the interpreter is going to perform a lookup in your current working directory, then it will search through the system defined library directories.



          The issue you are facing could be that your code is looking for a module that does not exist, you are calling the script from an incorrect directory, or the sys.path is setup incorrectly.



          I could help more if you showed how you instantiated the interpreter, pwd output, and tree output.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 6:26









          Joshua Taylor EppinetteJoshua Taylor Eppinette

          1656




          1656























              0














              You are trying to import Redis from a package named util. Unless this package is part of your application, it does not exist.



              According to python-redis' documentation, here is how to import it:



              import redis
              # then use redis.Redis(...)


              or, equivalently:



              from redis import Redis
              # then use Redis(...)





              share|improve this answer



























                0














                You are trying to import Redis from a package named util. Unless this package is part of your application, it does not exist.



                According to python-redis' documentation, here is how to import it:



                import redis
                # then use redis.Redis(...)


                or, equivalently:



                from redis import Redis
                # then use Redis(...)





                share|improve this answer

























                  0












                  0








                  0







                  You are trying to import Redis from a package named util. Unless this package is part of your application, it does not exist.



                  According to python-redis' documentation, here is how to import it:



                  import redis
                  # then use redis.Redis(...)


                  or, equivalently:



                  from redis import Redis
                  # then use Redis(...)





                  share|improve this answer













                  You are trying to import Redis from a package named util. Unless this package is part of your application, it does not exist.



                  According to python-redis' documentation, here is how to import it:



                  import redis
                  # then use redis.Redis(...)


                  or, equivalently:



                  from redis import Redis
                  # then use Redis(...)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 22 at 7:09









                  Valentin LorentzValentin Lorentz

                  6,92753555




                  6,92753555



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293423%2fhow-do-i-import-the-redis-python-module%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해