使用cx_freeze将我的程序转换为EXE后,出现以下错误:
Traceback (most recent call last):
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 292, in s
sl_wrap_socket
context.load_verify_locations(ca_certs, ca_cert_dir)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\adapters.py", line 376, in send
timeout=timeout
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 559,
in urlopen
body=body, headers=headers)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 345,
in _make_request
self._validate_conn(conn)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 784,
in _validate_conn
conn.connect()
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 252, in
connect
ssl_version=resolved_ssl_version)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 294, in s
sl_wrap_socket
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "genderator.py", line 109, in <module>
File "genderator.py", line 62, in checkLimits
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\genderize\__init__.py", line 88, in get
params=params)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 480, in get
return self.request('GET', url, **kwargs)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\adapters.py", line 447, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 2] No such file or directory
即使我没有明确使用请求库,我也认为Genderize会这样做。所以我已经阅读了几篇关于它的帖子,并尝试将路径传递给我的cacert.pem文件,但它仍然无法解决我的问题。这是我格式化setup.py文件的方式:
from cx_Freeze import setup, Executable
import requests.certs
import sys
executable = Executable( script = "genderator.py" )
# Add certificate to the build
options = {
"build_exe": {
'include_files' : [(requests.certs.where(), 'cacert.pem')]
}
}
setup(
version = "0",
requires = ["requests"],
options = options,
executables = [executable])
我在Windows 7 64bit上使用Python 3.4.4。知道我做错了吗?