我的系统是Ubuntu 16.04,我的Python版本是3.5。我已使用Python包装器将vtk 7.1.0
安装到/home/why/software/vtk/7.1.0/
中。此外,我将以下行添加到.bashrc
export PYTHONPATH=$PYTHONPATH:/home/why/software/vtk/7.1.0/lib/python3.5/site-packages
我可以在ipython3中导入vtk
并正常使用它。
但是当我按
安装mayavi
时
sudo -H pip3 install mayavi
我收到以下错误:
Running setup.py bdist_wheel for mayavi ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1_ze16zr/mayavi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp55qp27ekpip-wheel- --python-tag cp35:
running bdist_wheel
running build
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-1_ze16zr/mayavi/setup.py", line 499, in <module>
**config
File "/usr/lib/python3/dist-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 179, in run
self.run_command('build')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-build-1_ze16zr/mayavi/setup.py", line 311, in run
build_tvtk_classes_zip()
File "/tmp/pip-build-1_ze16zr/mayavi/setup.py", line 297, in build_tvtk_classes_zip
gen_tvtk_classes_zip()
File "tvtk/setup.py", line 50, in gen_tvtk_classes_zip
from tvtk.code_gen import TVTKGenerator
File "/tmp/pip-build-1_ze16zr/mayavi/tvtk/code_gen.py", line 10, in <module>
import vtk
ImportError: No module named 'vtk'
如何解决这个问题?非常感谢你的帮助。
修改
根据MikeMüller的建议,我现在可以安装mayavi
。但是我运行了一个简单的测试,如下所示:
In [1]: import numpy as np
In [2]: from mayavi import mlab
In [3]: x, y, z, value = np.random.random((4, 40))
In [4]: mlab.points3d(x, y, z, value)
Out[4]: <mayavi.modules.glyph.Glyph at 0x7f3190ffca98>
我只是得到一个没有任何数字的灰色死窗口。那么如何解决这个问题?
答案 0 :(得分:2)
如果您想/需要以root身份安装,请先更改为root,然后导出sudo -s
export PYTHONPATH=$PYTHONPATH:/home/why/software/vtk/7.1.0/lib/python3.5/site-packages
pip3 install mayavi
:
mlab.show()
Root不会确认您设置为其他用户的环境变量。
您需要致电import numpy as np
from mayavi import mlab
x, y, z, value = np.random.random((4, 40))
mlab.points3d(x, y, z, value)
mlab.show()
来展示您的可视化:
jar cvfe myJarFile.jar package.MyMainClass package/*.class