问题描述
使用pip安装第三方库时,报错:
(chatglm) L4EX:ChatGLM-6B-main apple$ pip3 install transformers==4.27.1
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography import x509
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. A future version of pip will drop support for Python 2.7. More details about Python2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
ERROR: Could not find a version that satisfies the requirement transformers==4.27.1 (from versions: 0.1, 2.0.0,2.1.0, 2.1.1, 2.2.0, 2.2.1, 2.2.2, 2.3.0)
ERROR: No matching distribution found for transformers==4.27.1
原因分析
首先我在anaconda下创建了一个新的环境,问题是在这个新环境中安装第三方库时出现的。
网上查的资料说,如果Python的路径是python3的话就不会出问题。我查看了python的版本:
python -V
返回的是3.10.9 版本没问题。再查看位置
which python
返回的是**/Users/apple/opt/anaconda3/bin/python**
网上的资料在这里往往会显示usr/local下的路径,所以我感觉可能是因为python多版本的问题,然后进一步查找了pip的路径,发现pip和pip3都在**/usr/local/bin/**下。最终在pip install加上python3 -m解决问题。
解决方案
python3 -m pip install transformers==4.27.1