According to the doc I can direct pip to use my private pypi repository instead of the official one:
For pip this can be done by setting the environment variable PIP_INDEX_URL in your .bashrc/.profile/.zshrc:
export PIP_INDEX_URL=http://localhost:8080/simple/
So I added my private repository(e.g., http://pypi.mycompany.com/simple
) into /etc/profile
on my Debian server. However pip still raises error:
john@server:~$ sudo pip install ipython
Downloading ...
Cannot fetch index base URL https://pypi.python.org/simple/
...
Looks like pip ignores the environment variable PIP_INDEX_URL
I've set. Why?
Update:
Following @Ivo's direction, I found my Python didn't see the variable at all:
john@server:~$ sudo python -c "import os; print(os.getenv('PIP_INDEX_URL'))"
None
Found it. It's simple: sudo
by default will not use the environment variables for security reasons. To tell sudo
preserve env variables, -E
option can be used, e.g.
sudo -E pip install ipython
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With