Using pip behind a proxy with CNTLM

前端 未结 30 2229
囚心锁ツ
囚心锁ツ 2020-11-22 11:00

I am trying to use pip behind a proxy at work.

One of the answers from this post suggested using CNTLM. I installed and configured it per this other post, but runnin

相关标签:
30条回答
  • 2020-11-22 11:32

    For windows users: if you want to install Flask-MongoAlchemy then use the following code

    pip install Flask-MongoAlchemy --proxy="http://example.com:port"**
    
    0 讨论(0)
  • 2020-11-22 11:32

    If you are connecting to the internet behind a proxy, there might be problem in running the some commands.

    Set the environment variables for proxy configuration in the command prompt as follows:

    set http_proxy=http://username:password@proxyserver:proxyport
    set https_proxy=https://username:password@proxyserver:proxyport
    
    0 讨论(0)
  • 2020-11-22 11:33

    You can continue to use pip over HTTPS by adding your corporation's root certificate to the cacert.pem file in your site-packages/pip folder. Then configure pip to use your proxy by adding the following lines to ~/pip/pip.conf (or ~\pip\pip.ini if you're on Windows):

    [global]
    proxy = [user:passwd@]proxy.server:port
    

    That's it. No need to use third party packages or give up HTTPS (of course, your network admin can still see what you're doing).

    0 讨论(0)
  • 2020-11-22 11:33

    I got the error:

    chris@green:~$ sudo http_proxy=http://localhost:3128 pip install django==1.8.8 
    Downloading/unpacking django==1.8.8
      Cannot fetch index base URL http://pypi.python.org/simple/
      Could not find any downloads that satisfy the requirement django==1.8.8
    No distributions at all found for django==1.8.8
    Storing complete log in /home/chris/.pip/pip.log
    

    (The proxy server's port is ssh port forwarded to localhost:3128).

    I had to set both http and https proxies to make it work:

    chris@green:~$ sudo http_proxy=http://localhost:3128 https_proxy=http://localhost:3128 pip install django==1.8.8
    Downloading/unpacking django==1.8.8
      Downloading Django-1.8.8.tar.gz (7.3Mb): 7.3Mb downloaded
      Running setup.py egg_info for package django
    
        warning: no previously-included files matching '__pycache__' found under directory '*'
        warning: no previously-included files matching '*.py[co]' found under directory '*'
    Installing collected packages: django
      Running setup.py install for django
    
        warning: no previously-included files matching '__pycache__' found under directory '*'
        warning: no previously-included files matching '*.py[co]' found under directory '*'
        changing mode of build/scripts-2.7/django-admin.py from 644 to 755
        changing mode of /usr/local/bin/django-admin.py to 755
        Installing django-admin script to /usr/local/bin
    Successfully installed django
    Cleaning up...
    

    as http://pypi.python.org/simple/ redirects to https://pypi.python.org/simple but pip's error does not tell you.

    0 讨论(0)
  • 2020-11-22 11:33

    for windows go to C:/ProgramData/pip/pip.ini, and set

    [global]

    proxy = http://YouKnowTheRest

    with your proxy details. This permanently configures the proxy for pip.

    0 讨论(0)
  • 2020-11-22 11:34

    At CentOS (actually I think all linux distros are similar) run

    env|grep http_proxy
    

    and

    env|grep https_proxy
    

    check what is the output of those commands (they should contain your proxy addresses).

    If the outputs are empty or have incorrect values, modify them, for ex:

    export http_proxy=http://10.1.1.1:8080
    export https_proxy=http://10.1.1.1:8080
    

    Now try to fetch and install some packages by using pip:

    pip --proxy http://10.1.1.1:8080 install robotframework
    

    and actually I have never met the case when it didn't work. For some systems you need to be a root (sudo is not enough).

    0 讨论(0)
提交回复
热议问题