我必须扩展古代学生所做的代码。在安装了所有需要的库之后,我终于尝试了代码并得到了这个错误:
$ ./main
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 39, in <module>
import _tkinter
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2237, in _find_and_load
return _find_and_load_unlocked(name, import_)
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2226, in _find_and_load_unlocked
module = _SpecMethods(spec)._load_unlocked()
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1191, in _load_unlocked
return self._load_backward_compatible()
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1161, in _load_backward_compatible
spec.loader.load_module(spec.name)
File "ExtensionLoader__tkinter.py", line 22, in <module>
File "ExtensionLoader__tkinter.py", line 3, in __bootstrap__
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2237, in _find_and_load
return _find_and_load_unlocked(name, import_)
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2224, in _find_and_load_unlocked
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named 'imp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/cx_Freeze-4.3.4-py3.4-linux-x86_64.egg/cx_Freeze/initscripts/Console.py", line 27, in <module>
File "main.py", line 13, in <module>
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2237, in _find_and_load
return _find_and_load_unlocked(name, import_)
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2226, in _find_and_load_unlocked
module = _SpecMethods(spec)._load_unlocked()
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1191, in _load_unlocked
return self._load_backward_compatible()
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1161, in _load_backward_compatible
spec.loader.load_module(spec.name)
File "/home/aitech/Scrivania/folder_test/GUI_videoServer/mainFrame.py", line 4, in <module>
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2237, in _find_and_load
return _find_and_load_unlocked(name, import_)
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2226, in _find_and_load_unlocked
module = _SpecMethods(spec)._load_unlocked()
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1191, in _load_unlocked
return self._load_backward_compatible()
File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1161, in _load_backward_compatible
spec.loader.load_module(spec.name)
File "/usr/lib/python3.4/tkinter/__init__.py", line 41, in <module>
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named 'imp', please install the python3-tk package
我不认为代码中存在错误,因为他已经使用过了。 我安装了python3-tk包,我可以在命令代码中使用它。 在项目的setting.py中,已经有一行&#39; django_admin_bootstrapped&#39;之前&#39; django.contrib.admin&#39;在INSTALLED_APPS =()
我在Ubuntu上:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
我真的迷路了,如果有人可以帮助我,请提前谢谢你。
答案 0 :(得分:0)
我不知道你是否遇到了和我一样的问题,但我的问题是_tkinter正在导入&#39; imp&#39;没有使用python&#34;&#34; import&#34;接口,所以它没有用py2exe打包成可执行文件。我通过将options = {"includes": ["imp"]}
添加到setup.py中的设置功能来解决此问题。
如果这不是你的问题,我可以提供的唯一建议是imp.py应该在你的python安装中你的Lib文件夹的基目录中,你应该重新安装python来修复它。