我在我的Windows 7副本上安装了Winpython发行版。从它复制的文件夹中发布的iPython控制台和其他项目工作正常。
我想使用numpy的f2py模块来从Python调用Fortran子程序。我的理解是必须从命令行调用f2py,但系统似乎找不到f2py,当我用或不用标志调用它时返回ImportError: no module named site
。当我尝试从命令行运行python时,会返回相同的错误。
当我手动导航到Winpython目录(例如C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5
)并致电f2py -c --help-fcompiler
以查看是否在那里找到f2py时,我收到以下错误
Traceback (most recent call last):
File ".\lib\site.py", line 538, in main
main()
File ".\lib\site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File ".\lib\site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File ".\lib\site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File ".\lib\site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
line 516, in get_config_var
return get_config_vars().get(name)
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sysconfig.py",
line 449, in get_config_vars
import re
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\re.py", line 1
05, in <module>
import sre_compile
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_parse.py"
", line 14, in <module>
import sre_parse
File "C:\Users\AGK\WinPython-32bit-2.7.5.3\python-2.7.5\lib\sre_constants.py",
line 17, in <module>
from sre_constants import *
File "C:\Users\konings\WinPython-32bit-2.7.5.3\pyt
py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
有人可以向我解释这个错误意味着什么和/或如何在Winpython中使用f2py吗?谢谢!
答案 0 :(得分:1)
您可以设置指向这些模块所在文件夹的环境变量PYTHONPATH
。这应解决ImportError
s。