pip install "numpy" 在 android chaquopy 中导致错误

Posted

技术标签:

【中文标题】pip install "numpy" 在 android chaquopy 中导致错误【英文标题】:pip install "numpy" causing error in android chaquopy 【发布时间】:2021-04-11 21:13:11 【问题描述】:

您好,我一直在尝试使用 chaquopy 来运行我的 python 脚本,但我在导入部分遇到了麻烦。当我运行不需要任何外部库且不使用您将在 build.gradle 中编写的安装代码的脚本时,它工作正常。

        python
            pip
                install "numpy"
            
        

我一插入安装代码,问题就出现了。它出现了下面写的错误消息。

> Task :app:generateDebugPythonRequirements
C:\Users\q\androidStudioProjects\Chaquopy_Practice\app\build\generated\python\bp.zip\pip\_vendor\ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
C:\Users\q\AndroidStudioProjects\Chaquopy_Practice\app\build\generated\python\bp.zip\pip\_vendor\ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
Chaquopy: Installing for armeabi-v7a
C:\Users\q\AndroidStudioProjects\Chaquopy_Practice\app\build\generated\python\bp.zip\pip\_vendor\ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
C:\Users\q\AndroidStudioProjects\Chaquopy_Practice\app\build\generated\python\bp.zip\pip\_vendor\ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.org/simple, https://chaquo.com/pypi-7.0
Collecting numpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/numpy/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /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("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /pypi-7.0/numpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /pypi-7.0/numpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /pypi-7.0/numpy/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /pypi-7.0/numpy/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /pypi-7.0/numpy/
  Could not fetch URL https://chaquo.com/pypi-7.0/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='chaquo.com', port=443): Max retries exceeded with url: /pypi-7.0/numpy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
Chaquopy: Exit status 1

我认为 SSLError 发生在其他人身上,但我找不到 SyntaxWarning: 'str' object ~~ 是关于什么的。

【问题讨论】:

SyntaxWarning 是由旧版本的 pip (github.com/pypa/pip/issues/7615) 引起的:我们将在下一版本的 Chaquopy 中修复此问题。 【参考方案1】:

问题本身不在 pip install 命令中。 真正的问题来自使用 anaconda 中的 python.exe 而不是原始的 python.exe。 下载 python 3.8.6 并更改 buildpython 路径后,我能够解决问题。

【讨论】:

你是如何使用 buildpython 的?它对我不起作用:::: python buildPython "C:/Program Files/Python39" pip install "numpy" @ParthaPaul: buildPython 应该是实际 python 可执行文件的路径,而不是包含它的目录。

以上是关于pip install "numpy" 在 android chaquopy 中导致错误的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 pip install 在 Windows 上安装 numpy?

MSYS2 pip install numpy 失败

Python用pip install安装Scipy报错

python3安装pandas执行pip3 install pandas命令后卡住不动的问题及安装scipysklearn库的numpy.distutils.system_info.NotFound(

在Amazon EC2上安装numpy

python中 pip install --upgrade pip出错