Blender - 导入pandas ImportError:没有名为pandas的模块

时间:2015-10-17 15:11:34

标签: python pandas blender

当我尝试在Blender中运行我的脚本时:

import bpy
import pandas as pd

datafr = pd.read_table("/Users/Admin/Desktop/Python/Programming/storage_ocp_ode.csv", delimiter = ",", index_col = 0)
...

我得到一个ImportError:没有名为pandas的模块。

Traceback (most recent call last):
File "/Users/Admin/Desktop/watertank1.blend/storageobject_flow.py", line 6, in <module>
ImportError: No module named 'pandas'
Error: Python script fail, look in the console for now...

但是当我使用命令行并在那里导入pandas时,它可以正常工作

Python 3.4.3 |Anaconda 2.3.0 (x86_64)| (default, Mar  6 2015, 12:07:41) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> 

我在使用OS X 10.11的Mac上使用Blender 2.76。

2 个答案:

答案 0 :(得分:2)

Per the docs

  

从blender.org发布的Blender版本包括在所有平台上安装完整的Python,这样做的缺点是你的系统中安装的任何 扩展都不会被Blender <找到/ strong>即可。 (我的重点)

     

有两种解决方法:

  • 删除Blender Python子目录,然后Blender将回退到系统Python并使用它代替..警告:

    The Python version must match the one that Blender comes with.
    
  • 将扩展名复制到Blender的Python子目录中,以便Blender可以访问它们,您也可以将整个Python安装复制到Blenders子目录中,替换Blender附带的那个。只要Python版本匹配并且路径在相同的相对位置创建,这就可以工作。这样做的好处是,您可以使用Blender和/或游戏玩家将此捆绑包重新分发给其他人,包括您依赖的任何扩展程序。

答案 1 :(得分:0)

我的解决方案是符号链接:

sudo ln -s /Users/Admin/anaconda/lib/python3.4/site-packages/pandas /Applications/blender.app/Contents/Resources/2.76/scripts/modules/pandas 

在此之后我必须使用numpy,dateutil,six.py和pytz做同样的事情,但现在它工作正常!