Pip can't install any package

前端 未结 3 1902
灰色年华
灰色年华 2020-12-30 16:23

Hello approximately about 2 weeks ago I started not being able to download python packages or even access the pypi website which is \"unreachable\" on chrome and firefox.

相关标签:
3条回答
  • 2020-12-30 16:47

    So for anybody searching for a solution, I found this which might not be optimal but at least it works, instead of pip install package use this command

    python.exe -m pip install package --proxy="proxy:port"

    You can find a big list of free proxies here : https://free-proxy-list.net/ (note that not all of them work and you might wanna try multiple before getting one that works)

    So for example you could use : python.exe -m pip install numpy --proxy="179.185.199.195:8080"

    And that works, Shraneid

    0 讨论(0)
  • 2020-12-30 16:47

    Using proxy from the previous answer will temporarily make things work - if you find a proxy that doesn't timeout, but it's not fixing the problem and using proxy will hamper your download speeds in most cases.

    What I've found is that you need to investigate your Python interpreter location and make sure the venv is not causing problems.

    For instance, if setuptools won't update then most likely there is already a part of your code or project that is continually using setuptools - prohibiting it from updating - and other packages need new versions of setuptools to install.

    For some reason this then causes "ConnectionResetError: An existing connection was forcibly closed by the remote host" to occur for most packages like tensorflow, keras, pandas etc.

    Recreating your venv in another empty location will reset any packages

    To do this in Pycharm:

    File -> Settings
    Project: -> Project Interpreter
    Project Interpreter -> drop down list -> show all
    
    Remove your current Python Interpreter location
    Add New Environment
    

    Then you will be asked to put in a location for your project: Using a new location here will solve the [Win10054] ConnectionResetError for package installations.

    Base Interpreter : point towards your python.exe location ( default usually : C:\Users\UserProfile\AppData\Local\Programs\Python\PythonXX\python.exe and replace XX with your current version and UserProfile with your profile )

    Most Important: Because you've setup a new location, install setuptools first, if it's already installed, then upgrade it first. After that you can migrate your code to the new venv and all new packages should work without any connectionResetErrors.

    0 讨论(0)
  • 2020-12-30 17:03

    There seems to be a problem with pip 20.3: https://github.com/pypa/pip/issues/9190 I have downgraded to 20.2.4 and it worked for me.

    (I know it cannot be the cause of the original problem, but I think this page is visited also by people currently experiencing the problem)

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