Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

python - Error during pip install -Please check proxy URL

I have installed anaconda on my machine with python 3.7, pip version 19.0.3

I am trying pip install from Windows command line. I am getting the error for all package installations tried through pip. It would be great if some one can help me out.

Command given: pip install lifetimes

Eror message:

Collecting lifetimes
Could not install packages due to an EnvironmentError: Please check proxy URL. It is malformed and could be missing the host.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To use pip behind a proxy, you can specify the proxy with the --proxy option.

pip install --proxy=https://user:pass@server:port packages

If you're going to do several pip installs in a given session, you can set your proxy variables in the terminal or command prompt. The lines below are taken from here. If you have the ability to define the environmental varibles, do that once and you should be good to go.

# Windows
set http_proxy=http://[username:password@]proxyserver:port
set http_proxy=https://[username:password@]proxyserver:port

# Linux
export https_proxy=https://[username:password@]proxyserver:port

At work, we still had some issues because some domains were not trusted, so you can add the following lines to tell pip that the following domains are okay.

--trusted-host pypi.python.org 
--trusted-host files.pythonhosted.org 
--trusted-host pypi.org

If you want to set up Anaconda to use the proxy without having to specify the proxy each time, you need to create a .condarc file in your home directory. Add the following lines to the .condarc file and you should be good to go. More information can be found here.

proxy_servers:
    http: http://user:pass@server:port
    https: https://user:pass@server:port

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...