【问题标题】:Blender - import pandas ImportError: No module named pandasBlender - 导入熊猫 ImportError:没有名为熊猫的模块
【发布时间】:2015-11-18 04:08:59
【问题描述】:

当我尝试在 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...

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

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。

【问题讨论】:

  • 如果this answer 没有帮助,那么this answer 会提供更多细节。您可能会从查看sys.path 的建议中猜到您可以添加额外的要搜索的路径。
  • 感谢您的建议: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 做同样​​的事情,但现在它工作正常!

标签: python pandas blender


【解决方案1】:

Per the docs:

从 blender.org 分发的 Blender 版本包括在所有平台上的完整 Python 安装,这有一个缺点,即 Blender 不会找到您在系统中安装的任何 Python 扩展。 (我的重点)

有两种解决方法:

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

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

【讨论】:

  • 谢谢,我尝试了你的第一次机会,现在我有这个错误消息: Traceback(最近一次调用最后一次):文件“/Users/Retter/Desktop/watertank1.blend/storageobject_flow.py”,行6,在 文件“/Applications/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/pandas/__init__.py”中,第 7 行,在 中从 pandas 导入hashtable, tslib, lib 文件“pandas/src/numpy.pxd”,第 157 行, init pandas.hashtable (pandas/hashtable.c:38262) ValueError: numpy.dtype has wrong size, try recompileing Error: Python script fail ,现在看看控制台...@unutbu
  • 我认为这意味着 Pandas 是针对更新版本的 NumPy 编译的,而不是安装在搅拌机安装中的 NumPy 版本。见stackoverflow.com/a/18369312/190597github.com/pydata/pandas/issues/7517stackoverflow.com/q/24122850/190597
【解决方案2】:

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

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 做同样​​的事情,但现在它可以正常工作了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多