简体   繁体   中英

Python installs packages globally, even with venv

I have python and try to use Venvs (best practice yada yada yada). Whenever I install a package globally, it also installs in ALL activated virtual environments, and vice versa. What is the fix?

I installed a package 'pandas' with Pip and it worked. I then activated the venv I was working with and pip freeze and 'pandas' were in the the venv. It should not have been because I had not installed it to the virtual environment yet.

I use: MacOS and Python 3.11

It is likely that your Virtual Environment is accessing packages installed in base or root. Best practice is to not install any package outside of virtual environments.

Also, I would recommend switching to Anaconda as a package manager, as it is less buggy and provides another alternative for accessing packages (using conda install ).

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