Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

virtualenv - frustrations over python venv and global modules

I wrote a web scraping programming a couple of months ago, which I had python -m venv venv did a bunch of pip install, checked and doubled check with pip list, everything looks fine.

And today I wanna scrape again so I did my source venv/bin/activate checked with pip list, everything looks fine, and just keep having no module of this and that...

But when I deactivated it, it falls back to my global installed modules, my program runs perfectly fine. I could't believe it so i did : rm -rf venv and python -m venv source venv/bin/activate pip install -r requirements.txt everything installed, check with pip list, and no module of this or that.

Anyone, please tell me what's happening? thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To ensure what python is being used and which python is linked to current pip:

  • which python to see where is the python executable (alternatively which python3, which python3.7, etc...)
  • running python show the version of python
  • pip -V shows the python to which it is linked
  • use python -m pip list to ensure the pip is linked to the python
  • python -m site shows were is the site-package located
  • writing python and hitting TAB multiple times shows what pythons are available in the path (os dependent)

This is more of a way to debug which python is being used.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...