简体   繁体   中英

Can't pip install package from github in virtual environment

I have written a python package package which is hosted on github and I would like to install it in a new virtual environment on my pc. It is the simplest package possible:

package
├── README.md
├── pkg
│   └── __init__.py
│   └── main.py
├── setup.py

I tried to install it using the following lines

(my_venv) C:\venv\my_venv>pip install git+https://github.com/MyUsername/package.git

But it installed itself in the following path, where things are installed when you use no venv,

c:\users\my_user\appdata\local\programs\python\python38\lib\site-packages instead of c:\venv\my_venv .

What should I do to correct this and install the package inside the virtual environment?

You have to use python -m pip to make it use the pip within your environment. Using pip without the -m flag might be pointing it to the global pip 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