8.11更新:之前用的python是3.7版本,反正在pycharm里面直接下第三方库就一直出问题,而且下下来之后运行也是报错
ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。
今天心灰意冷之下用了3.9版本的 python,结果不仅可以直接在pycharm里面下库不用去cmd pipinstall那么烦,而且运行也成功了
总而言之,总算可以开始学习了。
另外如果有朋友知道其中原因的话希望能够解答一下~
8.10
本来第三方库我一直是通过pycharm下的,很久没用python了今天要用一个新的库结果一直报错:
Could not fetch URL https://pypi.org/simple/mayavi/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/mayavi/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/mayavi/
WARNING: 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/mayavi/
WARNING: 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/mayavi/
WARNING: 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/mayavi/
WARNING: 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/mayavi/
ERROR: Could not find a version that satisfies the requirement mayavi (from versions: none)
ERROR: No matching distribution found for mayavi
翻阅了一些解决方案后通过cmd指令解决了,需要从镜像下载:
注:最后的mayavi是我要下载的库,根据需要自行更改库名
pip install -t D:\anaconda\envs\python37\Lib\site-packages -i https://pypi.douban.com/simple mayavi
还有一点要注意的就是如果直接pip install的话,会下载到默认python版本,我的默认python版本是2.7。如果电脑里有多个python版本就要像我这样通过
-t D:\anaconda\envs\python37\Lib\site-packages
来指定python版本
但是这个库下载成功之后,我以同样的指令下另外一个库又报错如下:
C:\Users\admin>pip install -t D:\anaconda\envs\python37\Lib\site-packages -i https://pypi.douban.com/simple seaborn
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 pip 21.0 will remove support for this functionality.
Looking in indexes: https://pypi.douban.com/simple
Collecting seaborn
Downloading https://pypi.doubanio.com/packages/b2/86/43b8c9138ef4c2a1c492fee92792c83c13799d0e2061ff810d3826d06cd1/seaborn-0.9.1-py2.py3-none-any.whl (216 kB)
|████████████████████████████████| 216 kB 113 kB/s
ERROR: Could not find a version that satisfies the requirement scipy>=0.17.1 (from seaborn) (from versions: none)
ERROR: No matching distribution found for scipy>=0.17.1 (from seaborn)
我换了个cmd指令之后就成功了:
注:seaborn是我要下载的库,自行更改库名
pip install seaborn -t D:\anaconda\envs\python37\Lib\site-packages -i https://pypi.douban.com/simple