简体   繁体   中英

Python virtual environment not working

I have activated the python virtual environment, but anyway when I run pip install * , the dependencies are installed to my local Python path. The same happens when I run the server in my Django project: python manage.py runserver -> the system is not using the virtual environment, but the python from my PC. What is the problem? Why my activated virtual environment does not work?

I am using MacOS. Everything worked until I erased all my data and installed again Python.

Thank you!

If the packages aren't getting installed within your virtual environment, it most likely is the case that you are not using the pip within your virtual environment (or may not have pip within your virtual environment at all, in which case it is defaulting to use the pip installed in /usr/local/bin/). First, check that you have a separate version of pip in your virtual environment located in ./your_virtual_environment_name/bin/pip....If you don't, install from the PyPA download page ( https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py ). When you go to install a package within your virtual environment, activate the virtual environment first using source ./bin/activate inside your virtual environment, then "cd .." and you'll use the pip installed within the virtual environment by typing: ./your_virtual_environment_name/bin/pip install * ....The installation will be in ./your_virtual_environment_name/lib/python3.6/site-packages/

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