简体   繁体   中英

Python virtual environment not installing packages in correct directory (python)

I have set up a virtual environment correctly have activated it and when I do "which python" it tells me the correct directory, but when I do pip install in the venv it installs the package in the default directory of the mac and not in my venv. I have tried using pycharm and installing packages with that, but it happens the same thing. Edit: Following I will do a walkthru of my steps, first I did python3 -m venv /path/to/new/virtual/environment , then I did source env/bin/activate , then I did which python and I got the intended directory, afterwards I did pip3 install numpy and I saw the installation process, then I did pip list and numpy was not there, I checked the directory manually and it still was not there. I retried all the same thing with pycharm with the same results.

Follow these steps in order -

In your current working directory

python3 -m venv venv
source venv/bin/activate
(venv) pip3 install library_name

To check if libraries were properly installed or not -

(venv) pip3 freeze

and check if your installed libraries is displayed on the terminal screen or not.

To deactivate the virtual environment -

(venv) deactivate

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