为什么 Blender 检测不到来自 Anaconda 的 python 个包?
Why aren't python packages from Anaconda being detected by Blender?
我最近一直在使用 Blender 来渲染物体的 3D 模型,并训练 SVM 来识别从某个角度拍摄的物体图片。要训练上述 SVM,我需要使用 "sklearn",它默认随 Anaconda 一起提供。
长话短说,我希望 Blender(运行s Python 3.4.2)使用我的 anaconda 安装(运行s Python 3.4.3).
我在这个网站上尝试了各种方法:
https://www.blender.org/api/blender_python_api_2_60_1/info_tips_and_tricks.html#bundled-python-extensions
1.) 我删除了 Blender.app 中的 "python" 文件夹。根据上述网站,Blender 应该回退到使用系统中安装的 python 版本(即通过 anaconda 安装的版本?对吗?)但我得到的是:
2.) 所以我进入选项 2。所以,我要做的是转到 anaconda 文件夹并复制两个文件夹 "bin" 和 "lib"
进入 Blender.app/Contents/Resources/2.76/python/(替换已经存在的 lib 和 bin 文件夹)
到目前为止一切都很好,我打开 Blender(没有错误)然后我写了一个简单的脚本:
from sklearn import svm
当我尝试 运行 它时,我收到以下错误消息:
Error: Python script fail, look in the console for now...
Traceback (most recent call last): File
"/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/Scripts/MarkTwo.blend/SimulationMarkOne.py",
line 5, in File
"/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/svm/init.py",
line 13, in
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, \ File
"/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/svm/classes.py",
line 4, in
from .base import _fit_liblinear, BaseSVC, BaseLibSVM File "/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/svm/base.py",
line 9, in
from . import libsvm_sparse File "sklearn/svm/libsvm_sparse.pyx", line 5, in init
sklearn.svm.libsvm_sparse (sklearn/svm/libsvm_sparse.c:7612) File
"/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/utils/init.py",
line 16, in
from .class_weight import compute_class_weight, compute_sample_weight File
"/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/utils/class_weight.py",
line 7, in
from ..utils.fixes import in1d File "/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/utils/fixes.py",
line 318, in
from scipy.sparse.linalg import lsqr as sparse_lsqr File "/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/scipy/sparse/linalg/init.py",
line 113, in
from .matfuncs import * File "/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/scipy/sparse/linalg/matfuncs.py",
line 20, in
import scipy.misc File "/Users/cusgadmin/...
Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/scipy/misc/init.py",
line 44, in
from . import doccer ImportError: cannot import name 'doccer' Error: Python script fail, look in the console for now...
此时我不知道还能做什么。我使用嵌入在 Blender 中的 Python 控制台来探索 sklearn 中的子包,令人惊讶的是我得到了不匹配的子包。
我很迷茫,不知道如何进行。非常感谢大家的帮助。
最好的,
红先生
好的伙计们,我找到了解决方案,我希望这对我之后的后代有所帮助等等;)
无论如何,我通过执行以下操作成功地导入了这些库:
- 保留 Blender 附带的所有相同文件(不要按照网站的建议删除 python 文件夹!)
- 转到子文件夹 "site-packages" 位于:"Blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages"
- 在那里,复制内容
"anaconda/lib/python3.4/site-packages" 并将它们粘贴到前面提到的文件夹中
- (除了 "numpy" 和 "requests" 文件夹之外,我复制了 "anaconda/lib/python3.4/site-packages" 中的所有内容,而且我也没有将文件 "numpy-1.9.1-py3.4.egg-info" 复制到文件夹中。)
希望这对您有所帮助,如果有帮助,不客气:)
我最近一直在使用 Blender 来渲染物体的 3D 模型,并训练 SVM 来识别从某个角度拍摄的物体图片。要训练上述 SVM,我需要使用 "sklearn",它默认随 Anaconda 一起提供。
长话短说,我希望 Blender(运行s Python 3.4.2)使用我的 anaconda 安装(运行s Python 3.4.3).
我在这个网站上尝试了各种方法: https://www.blender.org/api/blender_python_api_2_60_1/info_tips_and_tricks.html#bundled-python-extensions
1.) 我删除了 Blender.app 中的 "python" 文件夹。根据上述网站,Blender 应该回退到使用系统中安装的 python 版本(即通过 anaconda 安装的版本?对吗?)但我得到的是:
到目前为止一切都很好,我打开 Blender(没有错误)然后我写了一个简单的脚本:
from sklearn import svm
当我尝试 运行 它时,我收到以下错误消息:
Error: Python script fail, look in the console for now...
Traceback (most recent call last): File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/Scripts/MarkTwo.blend/SimulationMarkOne.py", line 5, in File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/svm/init.py", line 13, in from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, \ File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/svm/classes.py", line 4, in from .base import _fit_liblinear, BaseSVC, BaseLibSVM File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/svm/base.py", line 9, in from . import libsvm_sparse File "sklearn/svm/libsvm_sparse.pyx", line 5, in init sklearn.svm.libsvm_sparse (sklearn/svm/libsvm_sparse.c:7612) File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/utils/init.py", line 16, in from .class_weight import compute_class_weight, compute_sample_weight File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/utils/class_weight.py", line 7, in from ..utils.fixes import in1d File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/sklearn/utils/fixes.py", line 318, in from scipy.sparse.linalg import lsqr as sparse_lsqr File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/scipy/sparse/linalg/init.py", line 113, in from .matfuncs import * File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/scipy/sparse/linalg/matfuncs.py", line 20, in import scipy.misc File "/Users/cusgadmin/... Perception/blender-2.76b-OSX_10.6-x86_64/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages/scipy/misc/init.py", line 44, in from . import doccer ImportError: cannot import name 'doccer' Error: Python script fail, look in the console for now...
此时我不知道还能做什么。我使用嵌入在 Blender 中的 Python 控制台来探索 sklearn 中的子包,令人惊讶的是我得到了不匹配的子包。
我很迷茫,不知道如何进行。非常感谢大家的帮助。
最好的, 红先生
好的伙计们,我找到了解决方案,我希望这对我之后的后代有所帮助等等;)
无论如何,我通过执行以下操作成功地导入了这些库:
- 保留 Blender 附带的所有相同文件(不要按照网站的建议删除 python 文件夹!)
- 转到子文件夹 "site-packages" 位于:"Blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages"
- 在那里,复制内容 "anaconda/lib/python3.4/site-packages" 并将它们粘贴到前面提到的文件夹中
- (除了 "numpy" 和 "requests" 文件夹之外,我复制了 "anaconda/lib/python3.4/site-packages" 中的所有内容,而且我也没有将文件 "numpy-1.9.1-py3.4.egg-info" 复制到文件夹中。)
希望这对您有所帮助,如果有帮助,不客气:)