与PIP安装Mayavi的 - 没有模块名为VTK(installing Mayavi with p

2019-06-27 12:50发布

我想使用Mayavi的。

情况

  • 我用一台MacBook Air,用OSX 10.7.3。
  • 我使用Python 2.7.2
  • 我曾经virtualenv安装。 但是,我没有使用过此安装。

我已经手动安装了所有的IT的依赖性,包括VTK

对于VTK ,我跟着它的安装指南和安装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是空的。

Answer 1:

你的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



Answer 2:

我在Debian但这应该为你工作,以及

我坚持没有结果VTK安装到virtualenv中,搜索小时后我做了以下内容和它的工作。

  1. 从仓库全系统安装python-VTK

  2. 副本VTK文件夹从/usr/lib/pymodules/python2.7到/PATH/TO/YOUR/VIRTUALENV/lib/python2.7/site-packages

在你的情况下,全系统的Python包文件夹可能会有所不同,但你可以很容易地发射了系统蟒蛇,然后输入以下发现:

import vtk,sys
print(sys.modules['vtk'])

经过这一招Mayavi的使用PIP成功地安装到我的virtualenv安装Mayavi的画中画安装设想。

编辑:而不是复制它可能会更好,只是符号链接在步骤2中的文件夹



Answer 3:

我有同样的问题,首先回答问题并没有帮助我,因为PIP是在正确的目录,但事实证明我没有安装VTK - 运行sudo易于得到安装python-vtk的固定的问题,我能成功运行PIP后安装Mayavi的。



Answer 4:

安装与安装在pyenv蟒蛇Mayavi的时候我有同样的问题,我通过复制目录解决了这个问题/home/myname/.pyenv/versions/2.7.12/lib/python2.7/site-packages ,下面是我的方法:

  1. 安装vtkpython-vtk

     sudo apt-get install vtk6 sudo apt-get install python-vtk 
  2. 尝试python -c "import vtk" ,如果再次失败,则转到步骤3

  3. 进口错误可能由VTK包文件夹中当前的蟒蛇造成的损失,所以我们应该找到vtk的文件夹,复制到当前的Python(最有可能在pyenv垫片目录中的蟒蛇)的目录。

    vtk的文件夹在我的Ubuntu的路径

     /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 
  4. 尝试python -c "import vtk"一次。

  5. 如果没有导入错误,只是做

     pip install mayavi 


Answer 5:

我在坚持sudo安装了好几次,终于得到了解决,不知道该怎么解释。

sudo python2 -m pip install mayavi

sudo python3 -m pip install mayavi


Answer 6:

我使用自制安装VTK:

$ brew install vtk

希望这可以帮助。



文章来源: installing Mayavi with pip - no module named vtk