python - 你能把 pyi_rth_certifi 放在 EXE 文件中吗?
问题描述
后
- 尝试安装 auto-py-to-exe ( https://pypi.org/project/auto-py-to-exe/ )
- 对我的安装问题进行排序(如何将 .py 转换为 .exe - pip install auto-py-to-exe 有效,但 auto-py-to-exe 无效)
- 修复有关 ModuleNotFoundError: No module named 'pandas' 的问题(无法将 Python 文件作为 .exe 文件运行,出现错误 'ModuleNotFoundError: No module named 'pandas')
我现在面临错误
Traceback (most recent call last):
File "site-packages\PyInstaller\loader\rthooks\pyi_rth_certifi.py", line 11, in <module>
File "c:\users\hp\appdata\ local\programs\python\python37-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "ssl.py", line 98, in <module>
ModuleNotFoundError: No module named '_ssl"
[3668] Failed to execute script pyi_rth_certifi
ImportError: DLL load failed: The specified procedure could not be found.
[6236] Failed to execute script pyi_rth_certifi
我认为 _ssl 已经安装在我的计算机上。
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\HP>openssl version
OpenSSL 1.1.1c 28 May 2019
这是我可以在我的计算机上找到的 4 个 pyi_rth_certifi 实例(单击链接打开屏幕截图)-
当我运行软件时,当前命令是
pyinstaller -y --hidden-import pandas --hidden-import _ssl --hidden-import ssl "C:/Users/HP/Documents/Python Scripts/EbayWebScraper.py"
我查看了以下内容,但仍然无法解决问题。
- ImportError:没有名为 _ssl 的模块
- 为什么在 python3.7 版本上调用 python3 test.py 时提示 ModuleNotFoundError: No module named '_ssl'
- 无法在 python3.6 中导入 ssl:ModuleNotFoundError: No module named '_ssl'
我尝试按照此链接中的说明进行操作 - https://help.duo.com/s/article/3935?language=en_US
C:\Users\HP>install openssl
'install' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\HP>easy_install pyOpenSSL
Searching for pyOpenSSL
Best match: pyOpenSSL 19.0.0
Adding pyOpenSSL 19.0.0 to easy-install.pth file
Using c:\users\hp\anaconda3\lib\site-packages
Processing dependencies for pyOpenSSL
Finished processing dependencies for pyOpenSSL
C:\Users\HP>easy_install pyobjc-System-Configuration
Searching for pyobjc-System-Configuration
Reading https://pypi.org/simple/pyobjc-System-Configuration/
Couldn't find index page for 'pyobjc-System-Configuration' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for pyobjc-System-Configuration
error: Could not find suitable distribution for Requirement.parse('pyobjc-System-Configuration')
C:\Users\HP>brew link openssl
'brew' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\HP>
我运行了这个脚本
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 12 05:39:34 2019
@author: HP
"""
import ssl
并得到以下输出
runfile('C:/Users/HP/Documents/Python Scripts/FixSSLIssue.py', wdir='C:/Users/HP/Documents/Python Scripts')
我尝试运行此脚本,但在语法方面出现了很多错误 -
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 12 05:39:34 2019
@author: HP
"""
import ssl
$ rpm -aq|grep openssl
openssl-0.9.8e-20.el5
openssl-0.9.8e-20.el5
我在原始脚本中添加了“import ssl”,但收到了“ssl 已导入但未使用”的消息。
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 10 13:19:25 2019
@author: HP
"""
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 8 22:38:25 2019
@author: HP
"""
import pandas as pd
from pandas import ExcelWriter
#from pandas import ExcelFile
#import urllib2
import urllib.request
import requests
#from urllib import urlopen
#from urllib2 import urlopen
#import requests
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup as b
import ssl
df1 = pd.DataFrame(columns=['Title', 'Row'])
df2 = pd.DataFrame(columns=['Price', 'Row'])
#BaseURL, Syntax1 and Syntax2 should be standard across all
#Ebay URLs, whereas Request and PageNumber can change
BaseURL = "https://www.ebay.co.uk/sch/i.html?_from=R40&_sacat=0&_nkw="
Syntax1 = "&_skc=50&rt=nc"
Request = "xbox"
Syntax2 = "&_pgn="
PageNumber ="2"
URL = BaseURL + Request + Syntax2 + PageNumber + Syntax1
Row = 0
HTML = urllib.request.urlopen(URL).read()
soup=b(HTML,"html.parser")
Res=requests.get(URL)
soup=BeautifulSoup(Res.text,'html.parser')
for post in soup.select("#ListViewInner a"):
if (post.get('title'))!=None:
(post.get('title'))
df1.loc[Row] = [(post.get('title')),Row]
Row = Row + 1
Row = 0
for price in soup.select("#ListViewInner li.lvprice"):
df2.loc[Row] = [(price), Row]
Row = Row + 1
# Read in first 100 lines of both data frames
Title_df = df1.head(100)
Price_df = df2.head(100)
df3 = pd.merge(left=Title_df,right=Price_df, left_on='Row', right_on='Row')
writer = ExcelWriter(r'C:\Users\HP\Documents\EbayTitlePrice.xlsx')
df3.to_excel(writer, sheet_name='Sheet1', startrow=2,startcol=2, index=False, header=False)
writer.save()
我试图卸载并重新安装 pyinstaller
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\HP>pip uninstall pyinstaller
WARNING: Skipping pyinstaller as it is not installed.
C:\Users\HP>pip install pyinstaller
Collecting pyinstaller
Requirement already satisfied: setuptools in c:\users\hp\anaconda3\lib\site-packages (from pyinstaller) (41.0.1)
Collecting pywin32-ctypes>=0.2.0 (from pyinstaller)
Using cached https://files.pythonhosted.org/packages/9e/4b/3ab2720f1fa4b4bc924ef1932b842edf10007e4547ea8157b0b9fc78599a/pywin32_ctypes-0.2.0-py2.py3-none-any.whl
Collecting pefile>=2017.8.1 (from pyinstaller)
Collecting altgraph (from pyinstaller)
Using cached https://files.pythonhosted.org/packages/0a/cc/646187eac4b797069e2e6b736f14cdef85dbe405c9bfc7803ef36e4f62ef/altgraph-0.16.1-py2.py3-none-any.whl
Requirement already satisfied: future in c:\users\hp\anaconda3\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.17.1)
Installing collected packages: pywin32-ctypes, pefile, altgraph, pyinstaller
Successfully installed altgraph-0.16.1 pefile-2019.4.18 pyinstaller-3.5 pywin32-ctypes-0.2.0
C:\Users\HP>
这是我所有已安装软件包的列表
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\HP>pip list
Package Version
---------------------------------- ---------
alabaster 0.7.12
altgraph 0.16.1
anaconda-client 1.7.2
anaconda-navigator 1.9.7
anaconda-project 0.8.3
asn1crypto 0.24.0
astroid 2.2.5
astropy 3.2.1
atomicwrites 1.3.0
attrs 19.1.0
Babel 2.7.0
backcall 0.1.0
backports.functools-lru-cache 1.5
backports.os 0.1.1
backports.shutil-get-terminal-size 1.0.0
backports.tempfile 1.0
backports.weakref 1.0.post1
beautifulsoup4 4.7.1
bitarray 0.9.3
bkcharts 0.2
bleach 3.1.0
bokeh 1.2.0
boto 2.49.0
Bottleneck 1.2.1
certifi 2019.6.16
cffi 1.12.3
chardet 3.0.4
Click 7.0
cloudpickle 1.2.1
clyent 1.2.2
colorama 0.4.1
comtypes 1.1.7
conda 4.7.10
conda-build 3.18.8
conda-package-handling 1.3.11
conda-verify 3.4.2
contextlib2 0.5.5
cryptography 2.7
cycler 0.10.0
Cython 0.29.12
cytoolz 0.10.0
dask 2.1.0
decorator 4.4.0
defusedxml 0.6.0
distributed 2.1.0
docutils 0.14
entrypoints 0.3
et-xmlfile 1.0.1
fastcache 1.1.0
filelock 3.0.12
Flask 1.1.1
future 0.17.1
gevent 1.4.0
glob2 0.7
greenlet 0.4.15
h5py 2.9.0
heapdict 1.0.0
html5lib 1.0.1
idna 2.8
imageio 2.5.0
imagesize 1.1.0
importlib-metadata 0.17
ipykernel 5.1.1
ipython 7.6.1
ipython-genutils 0.2.0
ipywidgets 7.5.0
isort 4.3.21
itsdangerous 1.1.0
jdcal 1.4.1
jedi 0.13.3
Jinja2 2.10.1
joblib 0.13.2
json5 0.8.4
jsonschema 3.0.1
jupyter 1.0.0
jupyter-client 5.3.1
jupyter-console 6.0.0
jupyter-core 4.5.0
jupyterlab 1.0.2
jupyterlab-server 1.0.0
keyring 18.0.0
kiwisolver 1.1.0
lazy-object-proxy 1.4.1
libarchive-c 2.8
llvmlite 0.29.0
locket 0.2.0
lxml 4.3.4
MarkupSafe 1.1.1
matplotlib 3.1.0
mccabe 0.6.1
menuinst 1.4.16
mistune 0.8.4
mkl-fft 1.0.12
mkl-random 1.0.2
mkl-service 2.0.2
mock 3.0.5
more-itertools 7.0.0
mpmath 1.1.0
msgpack 0.6.1
multipledispatch 0.6.0
navigator-updater 0.2.1
nbconvert 5.5.0
nbformat 4.4.0
networkx 2.3
nltk 3.4.4
nose 1.3.7
notebook 6.0.0
numba 0.44.1
numexpr 2.6.9
numpy 1.17.2
numpydoc 0.9.1
olefile 0.46
openpyxl 2.6.2
packaging 19.0
pandas 0.24.2
pandocfilters 1.4.2
parso 0.5.0
partd 1.0.0
path.py 12.0.1
pathlib2 2.3.4
patsy 0.5.1
pefile 2019.4.18
pep8 1.7.1
pickleshare 0.7.5
Pillow 6.1.0
pip 19.2.3
pkginfo 1.5.0.1
pluggy 0.12.0
ply 3.11
prometheus-client 0.7.1
prompt-toolkit 2.0.9
psutil 5.6.3
py 1.8.0
pycodestyle 2.5.0
pycosat 0.6.3
pycparser 2.19
pycrypto 2.6.1
pycurl 7.43.0.3
pyflakes 2.1.1
Pygments 2.4.2
PyInstaller 3.5
pylint 2.3.1
pyodbc 4.0.26
pyOpenSSL 19.0.0
pyparsing 2.4.0
pyreadline 2.1
pyrsistent 0.14.11
PySocks 1.7.0
pytest 5.0.1
pytest-arraydiff 0.3
pytest-astropy 0.5.0
pytest-doctestplus 0.3.0
pytest-openfiles 0.3.2
pytest-remotedata 0.3.1
python-dateutil 2.8.0
pytz 2019.1
PyWavelets 1.0.3
pywin32 223
pywin32-ctypes 0.2.0
pywinpty 0.5.5
PyYAML 5.1.1
pyzmq 18.0.0
QtAwesome 0.5.7
qtconsole 4.5.1
QtPy 1.8.0
requests 2.22.0
rope 0.14.0
ruamel-yaml 0.15.46
scikit-image 0.15.0
scikit-learn 0.21.2
scipy 1.2.1
seaborn 0.9.0
Send2Trash 1.5.0
setuptools 41.0.1
simplegeneric 0.8.1
singledispatch 3.4.0.3
six 1.12.0
snowballstemmer 1.9.0
sortedcollections 1.1.2
sortedcontainers 2.1.0
soupsieve 1.8
Sphinx 2.1.2
sphinxcontrib-applehelp 1.0.1
sphinxcontrib-devhelp 1.0.1
sphinxcontrib-htmlhelp 1.0.2
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.2
sphinxcontrib-serializinghtml 1.1.3
sphinxcontrib-websupport 1.1.2
spyder 3.3.6
spyder-kernels 0.5.1
SQLAlchemy 1.3.5
statsmodels 0.10.0
sympy 1.4
tables 3.5.2
tblib 1.4.0
terminado 0.8.2
testpath 0.4.2
toolz 0.10.0
tornado 6.0.3
tqdm 4.32.1
traitlets 4.3.2
unicodecsv 0.14.1
urllib3 1.24.2
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.15.4
wheel 0.33.4
widgetsnbextension 3.5.0
win-inet-pton 1.1.0
win-unicode-console 0.5
wincertstore 0.2
wrapt 1.11.2
xlrd 1.2.0
XlsxWriter 1.1.8
xlwings 0.15.8
xlwt 1.3.0
zict 1.0.0
zipp 0.5.1
这是从 Auto Py 到 Exe 的输出
Running auto-py-to-exe v2.6.5
Building in the current instances temporary directory at C:\Users\HP\AppData\Local\Temp\tmpelb7gpod
To get a new temporary directory, restart this application
Recursion Limit is set to 5000
Executing: pyinstaller -y --hidden-import pandas "C:/Users/HP/Documents/Python Scripts/EbayWebScraper2.py"
199264 INFO: PyInstaller: 3.5
199264 INFO: Python: 3.7.3
199264 INFO: Platform: Windows-10-10.0.17134-SP0
199265 INFO: wrote C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\EbayWebScraper2.spec
199273 INFO: UPX is not available.
199278 INFO: Extending PYTHONPATH with paths
['C:\\Users\\HP\\Documents\\Python Scripts',
'C:\\Users\\HP\\AppData\\Local\\Temp\\tmpelb7gpod']
199278 INFO: checking Analysis
199279 INFO: Building Analysis because Analysis-01.toc is non existent
199280 INFO: Initializing module dependency graph...
199285 INFO: Initializing module graph hooks...
199293 INFO: Analyzing base_library.zip ...
210249 INFO: Analyzing hidden import 'pandas'
210253 ERROR: Hidden import 'pandas' not found
210254 INFO: running Analysis Analysis-01.toc
210255 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\hp\appdata\local\programs\python\python37-32\python.exe
223325 INFO: Caching module hooks...
223354 INFO: Analyzing C:\Users\HP\Documents\Python Scripts\EbayWebScraper2.py
224259 INFO: Processing pre-safe import module hook urllib3.packages.six.moves
227879 INFO: Loading module hooks...
227881 INFO: Loading module hook "hook-certifi.py"...
227884 INFO: Loading module hook "hook-encodings.py"...
228093 INFO: Loading module hook "hook-pydoc.py"...
228095 INFO: Loading module hook "hook-xml.py"...
228325 INFO: Looking for ctypes DLLs
228325 INFO: Analyzing run-time hooks ...
228335 INFO: Including run-time hook 'pyi_rth_certifi.py'
228383 INFO: Looking for dynamic libraries
245088 INFO: Looking for eggs
245088 INFO: Using Python library c:\users\hp\appdata\local\programs\python\python37-32\python37.dll
245088 INFO: Found binding redirects:
[]
245126 INFO: Warnings written to C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\build\EbayWebScraper2\warn-EbayWebScraper2.txt
245318 INFO: Graph cross-reference written to C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\build\EbayWebScraper2\xref-EbayWebScraper2.html
245367 INFO: checking PYZ
245367 INFO: Building PYZ because PYZ-01.toc is non existent
245371 INFO: Building PYZ (ZlibArchive) C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\build\EbayWebScraper2\PYZ-01.pyz
247108 INFO: Building PYZ (ZlibArchive) C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\build\EbayWebScraper2\PYZ-01.pyz completed successfully.
247153 INFO: checking PKG
247154 INFO: Building PKG because PKG-01.toc is non existent
247154 INFO: Building PKG (CArchive) PKG-01.pkg
247204 INFO: Building PKG (CArchive) PKG-01.pkg completed successfully.
247209 INFO: Bootloader c:\users\hp\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
247209 INFO: checking EXE
247210 INFO: Building EXE because EXE-01.toc is non existent
247211 INFO: Building EXE from EXE-01.toc
247213 INFO: Appending archive to EXE C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\build\EbayWebScraper2\EbayWebScraper2.exe
247232 INFO: Building EXE from EXE-01.toc completed successfully.
247244 INFO: checking COLLECT
247245 INFO: Building COLLECT because COLLECT-01.toc is non existent
247245 INFO: Removing dir C:\Users\HP\AppData\Local\Temp\tmpelb7gpod\application\EbayWebScraper2
247258 INFO: Building COLLECT COLLECT-01.toc
247898 INFO: Building COLLECT COLLECT-01.toc completed successfully.
Moving project to: C:\Users\HP\output
Complete.
这是保存我的 OpenSSL 文件/文件夹的位置。
图片 1/2 -
这是 c:\users\hp\appdata\local\programs\python\python37-32\lib\site-packages\ 的内容
图片 1/4 -
图片 2/4 -
图 3/4 -
解决方案
推荐阅读
- swift - iPad Pro Measure App 如何计算人的身高?
- r - 如何处理 R 中的双冒号 (::) 和管道 (%>%) 符号?
- c - 为什么程序在 C 中的输入选项之后停止?
- typescript - 带有 Typescript 的不可变 JS:创建 Map / OrderedMap 时“没有重载匹配此调用”
- ms-access - SSMA(用于访问的 SQL Server 迁移助手)无法连接到 SQL Server
- python - 使用 Python、SQlite 和 bcrypt 在登录函数中获取与其哈希匹配的密码
- pyspark - Pyspark 使用 lpad 不接受长度函数
- excel - Excel VBA 从 Excel 表中写入数据的 SQL 查询
- ruby-on-rails - 为什么 Nokogiri 找不到这个 img 标签?
- node.js - 无法从日志缓存中检索日志