#author("2022-06-07T08:41:14+08:00","default:Admin","Admin") #author("2022-06-07T15:20:55+08:00","default:Admin","Admin") [[Python]] &color(red){※This article is based on Python 3.7.3}; #contents * pip安装第三方库 [#r75ed322] pip install scikit-learn #下载scikit-learn 只要在下载软件的后面加上==号,写入版本号即可! pip install 软件名==版本号 # 下载scikit-learn的0.18.0版本 pip install scikit-learn==0.18.0 # 以管理者身份下载scikit-learn的0.18.0版本 pip install --user-v scikit-learn==0.18.0 #将库中的python模块用作脚本去运行安装scikit-learn python -m pip install scikit-learn * 安装pip [#g96cc3cf] 安装python3.x的pip sudo apt-get install python3-pip * 问题 [#g05c16b9] ** pip无法升级 [#d5b36b31] 报错: #codeprettify{{ Collecting pip Using cached https://files.pythonhosted.org/packages/52/e1/06c018197d8151383f66ebf6979d951995cf495629fc54149491f5d157d0/pip-21.2.4.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\users\tzzha\appdata\local\temp\pip-build-nzbfrv\pip\setup.py", line 7 def read(rel_path: str) -> str: ^ SyntaxError: invalid syntax ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in c:\users\tzzha\appdata\local\temp\pip-build-nzbfrv\pip\ You are using pip version 8.1.2, however version 21.2.4 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. }} 解决 python -m pip install --user --upgrade pip==20.2.4 #(换成你想要的版本编号) ** ssl certificate [#xaf99a28] #codeprettify{{ 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/virtualenv/ Could not fetch URL https://pypi.org/simple/virtualenv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/virtualenv/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping }} *** 解决方法 [#s7babc1c] 先安装 virtualenv pip install virtualenv -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com ** Ubuntu urllib2.URLError:<urlopen error unknown url type:https> [#e5b73d1d] *** 原因 [#g9b3b7ec] 是因为 Python 不支持 openssl 造成的,需要重新编译安装 python 参考官网 Note HTTPS support is only available if Python was compiled with SSL support (through the ssl module). https://docs.python.org/3/library/http.client.html *** 解决方法 [#s7babc1c] 在安装python之前,需要先安装 openssl ./config sudo make sudo make install 安装 python 时如下配置之后安装 ./configure --prefix=/root/python38 --with-openssl=/root/openssl-1.1.0l --enable-shared make make install 注意:/root/openssl-1.1.0l路径为openssl官网下载的源码包解压后的文件夹路径 安装后的验证:启动 python 命令行然后输入下面 import ssl ** ubuntu WARNING: Download failure <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)> [#q5c18c48] *** 解决方法 [#ma9bff2d] sudo update-ca-certificates --fresh export SSL_CERT_DIR=/etc/ssl/certs ** AttributeError: module 'serial' has no attribute 'serial_for_url' [#p00b6ce7] *** 解决方法 [#gbf4ae42] 许多人从网上找到串口代码后,直接安装了serial,无法运行,然后又安装pyserial,出现上述问题,本文给出解决建议。 如果你是按上述情况操作的,即使卸载了serial也无济于事,必须将二者同时卸载,然后单独安装最新版本的pyserial库。 #hr(); コメント: #comment_kcaptcha