我想使用Mayavi。
virtualenv
。但我没有用它来安装。我手动安装了它的所有依赖项,包括VTK
。
对于VTK
,我按照其安装指南安装了python包装器。
现在,如果我打开一个新的终端窗口并打开python,我可以导入vtk
而不会出现任何错误。
我尝试使用以下命令安装Mayavi:
pip install mayavi
但发生以下错误:
Downloading/unpacking mayavi
Running setup.py egg_info for package mayavi
build_src
building extension "tvtk.array_ext" sources
building data_files sources
build_src: building npy-pkg config files
no previously-included directories found matching 'artwork'
no previously-included directories found matching 'docs/pdf'
Requirement already satisfied (use --upgrade to upgrade): apptools in /Library/Python/2.7/site-packages (from mayavi)
Requirement already satisfied (use --upgrade to upgrade): traits in /Library/Python/2.7/site-packages (from mayavi)
Requirement already satisfied (use --upgrade to upgrade): traitsui in /Library/Python/2.7/site-packages (from mayavi)
Requirement already satisfied (use --upgrade to upgrade): configobj in /Library/Python/2.7/site-packages (from apptools->mayavi)
Requirement already satisfied (use --upgrade to upgrade): pyface in /Library/Python/2.7/site-packages (from traitsui->mayavi)
Installing collected packages: mayavi
Running setup.py install for mayavi
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/Yasser/build/mayavi/setup.py", line 498, in <module>
**config
File "/Library/Python/2.7/site-packages/numpy-1.6.1-py2.7-macosx-10.7-intel.egg/numpy/distutils/core.py", line 186, in setup
return old_setup(**new_attr)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/numpy-1.6.1-py2.7-macosx-10.7-intel.egg/numpy/distutils/command/install.py", line 57, in run
r = self.setuptools_run()
File "/Library/Python/2.7/site-packages/numpy-1.6.1-py2.7-macosx-10.7-intel.egg/numpy/distutils/command/install.py", line 31, in setuptools_run
return old_install_mod._install.run(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/Yasser/build/mayavi/setup.py", line 303, in run
build_tvtk_classes_zip()
File "/Users/Yasser/build/mayavi/setup.py", line 290, in build_tvtk_classes_zip
gen_tvtk_classes_zip()
File "tvtk/setup.py", line 46, in gen_tvtk_classes_zip
from code_gen import TVTKGenerator
File "tvtk/code_gen.py", line 10, in <module>
import vtk
ImportError: No module named vtk
Complete output from command /usr/bin/python -c "import setuptools;__file__='/Users/Yasser/build/mayavi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/53/_trhc_0x0fb6kvx6bw_wrk500000gn/T/pip-Z4hpsW-record/install-record.txt:
running install
running build
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/Yasser/build/mayavi/setup.py", line 498, in <module>
**config
File "/Library/Python/2.7/site-packages/numpy-1.6.1-py2.7-macosx-10.7-intel.egg/numpy/distutils/core.py", line 186, in setup
return old_setup(**new_attr)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Library/Python/2.7/site-packages/numpy-1.6.1-py2.7-macosx-10.7-intel.egg/numpy/distutils/command/install.py", line 57, in run
r = self.setuptools_run()
File "/Library/Python/2.7/site-packages/numpy-1.6.1-py2.7-macosx-10.7-intel.egg/numpy/distutils/command/install.py", line 31, in setuptools_run
return old_install_mod._install.run(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/Yasser/build/mayavi/setup.py", line 303, in run
build_tvtk_classes_zip()
File "/Users/Yasser/build/mayavi/setup.py", line 290, in build_tvtk_classes_zip
gen_tvtk_classes_zip()
File "tvtk/setup.py", line 46, in gen_tvtk_classes_zip
from code_gen import TVTKGenerator
File "tvtk/code_gen.py", line 10, in <module>
import vtk
ImportError: No module named vtk
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/Users/Yasser/build/mayavi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/53/_trhc_0x0fb6kvx6bw_wrk500000gn/T/pip-Z4hpsW-record/install-record.txt failed with error code 1 in /Users/Yasser/build/mayavi
Storing complete log in /Users/Yasser/Library/Logs/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.1', 'console_scripts', 'pip')()
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/__init__.py", line 116, in main
return command.main(args[1:], options)
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 141, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 168, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/Users/Yasser/Library/Logs/pip.log'
我认为问题出在vtk
。
任何人都可以帮助我吗?
运行sudo pip install mayavi
无法解决问题。
我认为这可能会有所帮助
› which python
/usr/local/bin/python
› python
Python 2.7.2 (default, Feb 17 2012, 13:57:55)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> vtk
<module 'vtk' from '/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/VTK-5.10.0-py2.7.egg/vtk/__init__.pyc'>
>>>
我的PYTHONPATH
为空。
答案 0 :(得分:16)
我在Debian上,但这对你也有用
我坚持将vtk安装到virtualenv中,经过几个小时的搜索后没有任何结果我做了以下操作并且有效。
从系统存储库安装python-vtk
将/usr/lib/pymodules/python2.7中的vtk文件夹复制到/PATH/TO/YOUR/VIRTUALENV/lib/python2.7/site-packages
在您的情况下,系统范围的python包文件夹可能会有所不同,但您可以通过启动系统python并输入以下内容轻松找到它:
import vtk,sys
print(sys.modules['vtk'])
在这个技巧之后,使用pip install mayavi和pip install envisage将mayavi成功安装到我的virtualenv中。
编辑:而不是复制它可能最好只是在步骤2中对符号链接进行符号链接
答案 1 :(得分:10)
您的pip
可能正在使用其他python
,您使用vtk
安装/usr/local/bin/python
,pip
二进制文件使用/usr/bin/python
}。
检查:
$ head -n1 $(which pip)
为了解决问题,您可以选择使用virtualenv
,或使用pip
安装/usr/local/bin/python
:
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | /usr/local/bin/python
有关更多安装说明,请参阅http://www.pip-installer.org/en/latest/installing.html
答案 2 :(得分:8)
我有同样的问题,第一个答案对我没有帮助,因为pip在正确的目录中,但事实证明我没有安装vtk - 运行sudo apt-get install python-vtk解决了这个问题,之后我就能成功运行pip install mayavi。
答案 3 :(得分:3)
我在pyenv中安装python安装mayavi时遇到了同样的问题,我通过复制目录解决了这个问题/home/myname/.pyenv/versions/2.7.12/lib/python2.7/site-packages
,下面是我的方法:
安装vtk
和python-vtk
sudo apt-get install vtk6
sudo apt-get install python-vtk
尝试python -c "import vtk"
,如果再次失败,请转到第3步
导入错误可能是由于当前python中vtk包文件夹丢失引起的,所以我们应该找到vtk文件夹并复制到你当前的python(最有可能是pyenv shims目录下的python)的目录。
我的ubuntu中vtk文件夹的路径是
/usr/lib/python2.7/dist-packages/vtk
只需将vtk
文件夹复制到当前的python /site-packages
,例如
cp -r /usr/lib/python2.7/dist-packages/vtk /home/myname/pyenv/versions/2.7.12/lib/python2.7/site-packages
再次尝试python -c "import vtk"
。
如果没有导入错误,只需执行
pip install mayavi
答案 4 :(得分:1)
我坚持sudo
安装了好几次,终于解决了,不知道如何解释。
sudo python2 -m pip install mayavi
sudo python3 -m pip install mayavi
答案 5 :(得分:-1)
我使用Homebrew安装了vtk:
$ brew install vtk
希望这会有所帮助。