PIP安装PYINSTALLER出现问题的解决

文章描述了在使用pip安装pyinstaller时遇到的SSL错误,通过创建pip配置文件并指定镜像源解决了问题。然后成功使用pyinstaller打包Python程序,并提到了处理tensorflow模块的方法。此外,还讨论了conda环境中因代理设置导致的问题以及CONDA软件升级的注意事项,最后指出了解决pip与tensorflow版本冲突的策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.发现的问题

今天想给自己编译的PYTHON程序打个包,于是按照网上的操作,安装pyinstaller,如下:

C:\Users\xiao'wei>pip3 install pyinstaller
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/pyinstaller/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/pyinstaller/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/pyinstaller/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/pyinstaller/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))': /simple/pyinstaller/
Could not fetch URL https://pypi.org/simple/pyinstaller/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pyinstaller/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))) - skipping
ERROR: Could not find a version that satisfies the requirement pyinstaller (from versions: none)
ERROR: No matching distribution found for pyinstaller
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(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1123)'))) - skipping
WARNING: There was an error checking the latest version of pip.

弹出了关于PIP的很多错误。

2.解决方式

输入命令,

pip -v config list

出现如下提示:

C:\Users\xiao'wei>pip -v config list
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\xiao'wei\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\xiao'wei\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'c:\users\xiao'wei\appdata\local\programs\python\python39-32\pip.ini'

于是在第一个目录中,创建pip.ini,按照网址

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

成功。用以下命令完成python程序打包,连库一起打包。

pyinstaller -w -F fileren.py,exe存在dist目录中。

C:\点名>pyinstaller -w -F haodianming.py
298 INFO: PyInstaller: 5.13.0
299 INFO: Python: 3.9.2
300 INFO: Platform: Windows-10-10.0.19041-SP0
301 INFO: wrote C:\点名\haodianming.spec
312 INFO: Extending PYTHONPATH with paths
['C:\\点名']
684 INFO: checking Analysis
772 INFO: checking PYZ
805 INFO: checking PKG
806 INFO: Building because toc changed
807 INFO: Building PKG (CArchive) haodianming.pkg
2644 INFO: Building PKG (CArchive) haodianming.pkg completed successfully.

3.打包小记

del /s /q dist

del /s /q build

缺少tensorflow模块的话,加上pyinstaller  -w -F --hidden-import tensorflow test.py

另外,总体上分两步:

A.pyi-makespec -w main.py生成*.spec文件

B.更改spec文件参数,pyinstaller -F -w -i fav.ico test.spec生成exe文件

4.conda问题

(python33) C:\malaoshi\mineral>conda install keras
Collecting package metadata (repodata.json): failed

ProxyError: Conda cannot proceed due to an error in your proxy configuration.
Check for typos and other configuration errors in any '.netrc' file in your home directory,
any environment variables ending in '_PROXY', and any other system-wide proxy
configuration settings.

进入主目录(python33) C:\malaoshi\mineral>notepad C:\users\xiao'wei\.condarc

ssl_verify: true
channels:
  - defaults
  - conda-forge

CONDA升级软件需要关闭internet代理

5.pip安装pyinstaller后,与tensorflow等版本发生冲突,如何解决的问题。需要安装匹配的版本。

需要修改两个重要的文件:hook-disutils.py hook-tensorflow.py

参考网址:

1.

PyInstaller打包详解 | Yu's Home
2.成功解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.Check for typos an_一个处女座的程序猿的博客-CSDN博客

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weiyiwen1982

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值