Win7-64bit上的32位Python,导入错误

时间:2013-03-06 21:29:33

标签: windows-7 64-bit ipython

当我尝试从除Python安装目录以外的任何地方启动ipython qtconsole时,我会收到导入错误。它似乎只有在我运行 - > cmd.exe时才有效; cd C:\ Users \ me \ python \ Python27; ipython qtconsole;。

我已经尝试过批处理文件,但是如果我不在我的安装目录的上下文中运行它,它似乎仍然没有用。总是ipython脚本似乎在抱怨。这是输出...(这是来自ipython内部,CurrentWorkingDirectory作为我的桌面)

In [2]: !ipython qtconsole
Traceback (most recent call last):
  File "C:\Users\me\python\Python27\ipython-script.py", line 770, in <module
>
load_entry_point('ipython==0.12', 'console_scripts', 'ipython')()
File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\frontend\terminal\ipapp.py", line 402, in launch_new
_instance
  File "<string>", line 2, in initialize
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\config\application.py", line 84, in catch_config_err
or
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\frontend\terminal\ipapp.py", line 302, in initialize

  File "<string>", line 2, in initialize
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\config\application.py", line 84, in catch_config_err
or
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
 thon-0.12-py2.7.egg\IPython\core\application.py", line 325, in initialize
   File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\frontend\terminal\ipapp.py", line 297, in parse_comm
and_line
  File "<string>", line 2, in parse_command_line
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\config\application.py", line 84, in catch_config_err
or
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
thon-0.12-py2.7.egg\IPython\config\application.py", line 413, in parse_command_l
ine
  File "<string>", line 2, in initialize_subcommand
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
 thon-0.12-py2.7.egg\IPython\config\application.py", line 84, in catch_config_err
or
   File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
 thon-0.12-py2.7.egg\IPython\config\application.py", line 349, in initialize_subc
 ommand
   File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
 thon-0.12-py2.7.egg\IPython\utils\importstring.py", line 40, in import_item
  File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
 thon-0.12-py2.7.egg\IPython\frontend\qt\console\qtconsoleapp.py", line 30, in <m
 odule>
   File "c:\cpd-svn\branches\qt-4.8\win32-12-01\install\bin\lib\site-packages\ipy
 thon-0.12-py2.7.egg\IPython\external\qt.py", line 42, in <module>
 ImportError: Cannot import PySide >= 1.0.3 or PyQt4 >= 4.7

就像我说的那样,它在我的安装目录中运行得非常好,我96%确定我的ENV变量PATH,PYTHONPATH,PYTHONHOME是犹太人。我已经从删除它们,到一次完全重载一个目录,结果没有变化。

我确保存在Wow6432None Python条目(我尽量不污染这些条目)。

Ipython不是唯一一个有这样错误的模块(也有相同的解决方案),但这绝对是最烦人的(我无法从Run Prompt启动qtconsole!)

编辑::我确实挖了一个开始菜单条目,在更改'start in'属性后,我能够启动qtconsole,但我仍然不太明白为什么这个导入相对于当前执行。目录

2 个答案:

答案 0 :(得分:0)

我认为这与生活在我所定义的PATH不直接位置的qtconsole依赖关系有关,我相信我的模块搜索PATHS中存在一些冲突。

我找到的最简单的解决方案是使用环境变量PYTHONPATH

自我的原帖以来已经有一段时间了,从那以后有几件事发生了变化,但我认为重要的因素是:

- 小心在64位Windows上安装32位python。

- 使用PYTHONPATH包含重要的子目录,例如'/ install-dir / Lib'或其他任何子目录。

如果你的env变量仍然有问题,请使用绝对命令作为故障保护(将它们包装在一个易于使用的脚本中),

C:\Users\johnny42\python\Python27\pythonw.exe
C:\Users\johnny42\python\Python27\ipython-script.py qtconsole

以上示例应该在一行上。不要只是复制并粘贴它。

答案 1 :(得分:0)

我的64位Windows操作系统中有Python 32位。即使我有类似的错误“c:\ cpd-svn \ branches \ qt-4.8 \ win32-12-01 \ install \ bin”。我不知道它在哪里设置。您能否分享一下您从哪里获得这条路径的发现?它应该用哪条路径更新?