我正在使用python 3.4.3 32位版本在Windows上使用Pycharm。在那里我导入boto3。
在IDE上运行时一切正常,但是当我尝试使用cx_freeze生成.exe时,boto3似乎因以下堆栈跟踪而失败。
Traceback (most recent call last):
File "C:\tools\pythonx86_32\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "c:/Users/Rui/PycharmProjects/VOConverter/upload_aws.py", line 1, in <module>
from boto3.session import Session
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2212, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\tools\pythonx86_32\lib\site-packages\boto3\__init__.py", line 16, in <module>
from boto3.session import Session
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\tools\pythonx86_32\lib\site-packages\boto3\session.py", line 17, in <module>
import botocore.session
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\tools\pythonx86_32\lib\site-packages\botocore\session.py", line 25, in <module>
import botocore.config
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
File "C:\tools\pythonx86_32\lib\site-packages\botocore\config.py", line 19, in <module>
from six.moves import configparser
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2281, in _handle_fromlist
File "C:\tools\pythonx86_32\lib\site-packages\six.py", line 92, in __get__
result = self._resolve()
File "C:\tools\pythonx86_32\lib\site-packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\tools\pythonx86_32\lib\site-packages\six.py", line 82, in _import_module
__import__(name)
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2224, in _find_and_load_unlocked
ImportError: No module named 'configparser'
我无法通过pip3.exe安装configparser,但无论如何,如果从PyCharm或通过命令行运行代码,该代码可以正常工作。 pip3的错误是:
Collecting configparser
Using cached configparser-3.3.0r2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "c:\tools\pythonx86_32\lib\site-packages\setuptools\__init__.py", line 4, in <module>
import distutils.core
File "c:\tools\pythonx86_32\lib\distutils\core.py", line 18, in <module>
from distutils.config import PyPIRCCommand
File "c:\tools\pythonx86_32\lib\distutils\config.py", line 7, in <module>
from configparser import ConfigParser
File "C:\Users\Rui\AppData\Local\Temp\pip-build-rjnpk61m\configparser\configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax
我系统上的版本:
python 3.4.3
pip 7.1.2 from c:\tools\pythonx86_32\lib\site-packages (python 3.4)
Metadata-Version: 2.0
Name: boto3
Version: 1.2.3
真的难倒这个。有帮助吗?感谢。
答案 0 :(得分:0)
使用pyinstaller而不是cx_freeze解决了这个问题。