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博客