无法通过python 2,7虚拟环境进行pip安装

时间:2020-05-19 15:02:33

标签: python-3.x python-2.7 virtualenv pyenv

我正尝试使用以下here on githubOCR项目。我正在使用python 3虚拟环境。我在Windows上。我使用requirements.txt成功安装了Python 3.6.7,但是,当我尝试执行python install setup.py时,出现以下错误:

AssertionError: you must install and use OCRopus with Python version 2.7 or later, but not Python 3.x

话虽如此,我还是回过头来,尝试通过Python 2.7 linkvirtual environmentpyenv-win一起使用。当我尝试使用虚拟环境requirements.txt安装python 2.7时,出现以下错误:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:380: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  SNIMissingWarning,
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': /simple/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (Caused by SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '_ssl.c:499: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping
C:\Users\User\venv\ocropus\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py:139: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning,
(ocropus)

这是否意味着我完全无法使用python 2.7安装这些python软件包?我必须在项目中使用此存储库。

2 个答案:

答案 0 :(得分:1)

再次阅读您的错误,您将在错误的第二行看到它:

This may cause the server to present an incorrect TLS certificate,

所有这些错误都是SSL警告,并且如错误所述,python告诉您将python升级到python 3,但是由于OCR项目使用python版本2,因此您有两种解决方案:

  1. 可以手动下载并安装要求
  2. 或者,退出OCR项目,因为python 2现在很旧,不再受支持

我希望我已经回答了你的问题

答案 1 :(得分:1)

对于以后偶然发现此问题的任何人,ocropy needs Python 2.7 but numpy and scipy newest versions dropped Python 2.7 support.不过,您仍然可以使用它们,但问题是我们的开发人员将停止支持错误修复。

我的问题主要是我在系统(Windows)上拥有的Python全局版本为3.6.7,而ocropus需要2.7。我为Python 2.7下载了一个损坏的可执行文件,没有安装 Scripts 文件夹,因此 pip 最终根本无法正常工作。

遵循this的教程,该教程显示了如何安装另一个版本的python(2.7),并且当我下载以下executable

时已解决了问题

为了与Python virtualenv正确使用2.7,请使用以下命令

# dont forget to add python.exe 
virtualenv -p C:\Python27\python.exe venv/ocropus

祝你好运。