Python:导入scipy引起了涉及已删除文件的回溯。

4

当我尝试在Python解释器(版本2.6.1)中导入scipy模块(版本0.11.0b1)时,我收到以下错误:


Traceback (most recent call last):

File "<stdin>", line 1, in module

File "/Users/...long path.../Desktop/scipy-0.11.0b1/scipy/\__init__.py", line 114, in module

ImportError: Error importing scipy: you cannot import scipy while
    being in scipy source directory; please exit the scipy source
    tree first, and relaunch your python intepreter.

问题在于Python正在读取一个不存在的文件。我一段时间前从桌面上删除了scipy目录,并尝试了几次重新启动解释器(和计算机)。为什么回溯仍然会引用一个不存在的文件?


你可能需要在python/site-packages目录下删除一些与包相关的信息。 - Alexander
2个回答

3
请按以下方式添加scipy路径。
from cx_Freeze import setup, Executable

include_files = ['C:\\Users\\User\\Anaconda\\Lib\\site-packages\\scipy']

setup(name = "ventana",
      options = {'build_exe': {'include_files':include_files}},
      version = "0.1",
      description = "ventana",
      executables = [Executable("REC.py")],)

0

看起来 Python 路径包含了你删除的目录的引用。

如果你:

import sys
print sys.path

你应该能够在其中看到对已删除目录的引用。如果是这种情况,从sys.path中删除该条目将允许您像以前一样导入scipy。

棘手的部分可能是找到注入sys.path的路径所在的位置。可能的位置包括(但不限于):您系统的site.py文件、PYTHONPATH环境变量,甚至是您的操作系统PATH环境变量。

祝你好运!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接