简体   繁体   中英

Python does not find installed modules

Python3.5 does not locate installed modules when invoked in virtual env.

  1. Create virtual env: python3.5 -m venv autogit/venv && cd autogit
  2. source venv/bin/activate
  3. which python == ...autogit/venv/bin/python Weird, would expect python3.5
  4. Add my python source code to /autogit and pip freeze>requirements.txt
  5. pip install -r requirements.txt
  6. ls venv/lib/python3.5/site-packages shows request-0-0-0-py3.5.egg-info and some other stuff
  7. Since dependencies are installed under python3.5 and which python revealed python rather than python3.5 , lets invoke the python3.5binary explicitly.... venv/bin/python3.5 autogit.py Get ImportError: No module named 'request

??? Where could python be looking for packages if not in my virtual env?

UPDATE The questions above remain unanswered; here are things I noticed since then and the workaround I used:

  • pip install produced a file request-0-0-0-py3.5.egg-info . It did NOT produce an actual request directory with the source code or binaries for this module. Also why is it version 0 0 0 that is fishy

  • After some googling I noticed the module I wanted seemed to be named requests not request which is what was in my source. I changed it requests, pip install , and everything works. It was hard to see that there was a mistake because pip install ing request did not fail

Have you got other Python versions installed? That might be the problem.

Try using pip3 instead of pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM