简体   繁体   中英

Pycharm pip install wont work behind a proxy

I'm trying to install packages from within Pycharm in Windows 10. I am behind a proxy, so I have set up the proxy information as well as my login details and my connection seems to work.

网络连接

My problem is that both pip and Setup_tools seems fails to connect to the internet and I get the following error after multiple connections retries have failed:

No matching distribution found for [package name]

For example, when I try to install Numpy:

我得到的错误

PS:

  • I have looked at a similar question over here , however I didn't find that helpful.

  • I have managed to get pip to work from the command prompt(CMD) after doing the following:

    1. Export the proxy settings:

      set http_proxy=http://username:password@proxyAddress:port

      set https_proxy=https://username:password@proxyAddress:port

    2. Install the package:

      pip install PackageName

For some reason, the following kind of install seem to not work (note this is the same kind of statement Pycharm is trying to use to install my packages):

pip install --proxy=https://username:password@proxy:port packageName

What am I doing wrong? How do I resolve this? Thanks in advance.

There might be a couple of reasons for your issue. The first that come to mind are:

  • did you try to go to Python3 executable path and try the same command from CMD?

     pip3.exe install --proxy=https://username:password@proxy:port packageName
  • you can also try the same command as above, but a bit changed:

     pip3.exe install packageName --proxy=https://username:password@proxy:port
  • are you sure the credentials are ok? (apparently the connection was successfull, I just saw the first image)

  • is the proxy up? (apparently the connection was successfull, I just saw the first image)

I'm using the latter command and it works fine with Python 3.5.x on Windows.

Create a System Environment Variable HTTPS_PROXY or HTTP_PROXY in windows with required authentication ( https://user:password@proxy:port ) in windows and restart Pycharm.

Then, without specifying proxy configuration inside Pycharm, install the package.

This is best solution:

pip install requests

If that command is not work in Pycharm , reason is proxy or web filtering and something like this.

For fixing this problem you could do these steps:

1. Go to pypi.org

2. Then find your package ( requests )

3. Then in Download section copy.targz link address

4. In Pycharm terminal type: pip install (your link address that you copied)

5. Now press enter, If you will know your package would need some dependencies so

repeat these steps for dependencies.

  • Note : Be careful on version of package dependencies that you need to install before install your main package.

Or you will be able use Proxy with this command:

pip install --proxy= https://username:password@proxy:port YourPackageName

In PyCharm you can specify the proxy in the options field in the Available Packages Dialog:

可用包对话框

This dialog is reachable from the Project Interpreter page by clicking the + button

**

Fix the pycharm proxy issue in Macbook pro to install libraries behind the corporate proxy:

**

go to System settings --> HTTP Proxy

Select Manual proxy configuration --> HTTP Proxy

  • Host Name: your company hostname --Example.com--

  • port number: specify your corporate proxy --port number--

Check Proxy Authentication: Give your system login credentials --> Login and password --> Check Reminder box

Check the connection: eg: http://www.google.com

在此处输入图像描述

Now you should be able to download libraries inside the proxy from pycharm.

If you want to install packages from terminal:

pip install --proxy http://username:password@proxy.com:port package-name

eg: pip install --proxy http://manojnirale:password%40@proxy.com:8080 spacy

Username:corporate id Password having special characters use Unicode Unicode for @ will be %40. Please find the below link for Unicode conversion https://r12a.github.io/app-conversion/

If you don't want to modify system or user environment variables, proxy address can be passed to PyCharm pip also with this modification of PyCharm Community Edition 2019.3.3.lnk (or another version) in Windows:

C:\Windows\System32\cmd.exe /c "SET HTTPS_PROXY=http://proxyAddress:port&& START /D ^"C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\bin^" pycharm64.exe"

链接设置

make sure to use cert options when installing. Path it to a cert. that will fill in the correct command that is issued By pycharm New versions of pip break all "pip install" commands

Add these to the options box --cert C:\Users\user_name\certs\ca-certificates.crt --ignore-requires-python

在此处输入图像描述

Pycharm 2021.2.1 and Python 3.9.0 installed

After one month of banging my head against the wall trying all the solutions posted on StackOverflow and other websites, I have found my way to solve the problem. The curious thing was that the proxy was transparent to see all the packages available, but if I tried to install one of them I always had errors answer like:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken b
y 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002861DE54F70>, 'Connection
 to pypi.org timed out. (connect timeout=15)')': /simple/netmiko/

I had tried changing the environment variables, setting the proxy with authentication on pycharm, or trying to execute it from the command line pip install everything , only one solution was missing, the urllib3 install and downgrade but how to do it if you can't take away the proxy server you have behind?
I was near to go to the company with a wifi extender to use it as a wifi port to connect to my smartphone like hotspot...... but.
My company laptop at home was working without a proxy and everything was working fine, I have loaded the urllib3 v1.25.11 on that pc, then I have looked for it into C:\Users\**my.user**\PycharmProjects\pythonProject2\venv\Lib\site-packages\ and I have put the urllib3 and urllibe-1.25.11.dist-info into a zip file and transferred to the pc with the proxy problem in the same place C:\Users\.......venv\Lib\site-packages\
I have started pycharm and tried to install urllib v1.25.11 ticking the specified version. On the first try, it has loaded the last version 1.26.6 , but I have done it again and the installation of urllib3 v1.25.11 was successful.
Then I have tried to install the other two packages and finally, everything was working as it should. I don't know why the people who have made the changes to pip and urllib3 and made it stop working behind a proxy didn't fix it in the next version and they left a lot of people into the shit. Now I can start to work.

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