我正在使用conda
来管理依赖项的共享Python项目。
我有两个导致我出现问题的库openCV
和python-pcl
。
openCV
需要numpy 1.7.*
。我只能看到一个conda
包:
>conda search -f opencv
Fetching package metadata .........
opencv * 2.4.8 np17py27_2 defaults
python-pcl
要求numpy 1.9.*
正常工作(据我所知)。只有一个conda package
:
>conda search -c ccordoba12 python-pcl
Fetching package metadata ...........
python-pcl * 0.2 nppy27_1 ccordoba12
安装numpy 1.7.1
时,以下python-pcl
代码会出错:
import pcl
import numpy as np
def main():
p = pcl.PointCloud(np.array([[1, 2, 3], [3, 4, 5]], dtype=np.float32))
seg = p.make_segmenter()
seg.set_model_type(pcl.SACMODEL_PLANE)
seg.set_method_type(pcl.SAC_RANSAC)
indices, model = seg.segment()
if __name__ == '__main__':
main()
错误是:
import pcl
File "/Users/MyName/anaconda/envs/MyDir/lib/python2.7/site-packages/pcl/__init__.py", line 2, in <module>
from ._pcl import *
File "__init__.pxd", line 861, in init pcl._pcl (pcl/_pcl.cpp:15775)
ValueError: numpy.ufunc has the wrong size, try recompiling
有没有一种简洁的方法可以解决这个问题,以便我可以与同事分享我的环境?
这是我的environment.yml文件:
name: TestEnv
channels:
- ccordoba12
- defaults
dependencies:
- boost=1.55.0=2
- eigen3=3.2.5=0
- flann=1.8.4=0
- icu=54.1=1
- pcl=1.7.2=3
- python-pcl=0.2=nppy27_1
- dateutil=2.4.1=py27_0
- freetype=2.4.10=1
- libpng=1.5.13=1
- matplotlib=1.3.1=np17py27_0
- numpy=1.7.1=py27_2
- opencv=2.4.8=np17py27_2
- openssl=1.0.2l=0
- pip=9.0.1=py27_1
- pyparsing=1.5.6=py27_0
- python=2.7.13=0
- pytz=2017.2=py27_0
- readline=6.2=2
- scipy=0.13.2=np17py27_1
- setuptools=27.2.0=py27_0
- six=1.10.0=py27_0
- sqlite=3.13.0=0
- tk=8.5.18=0
- wheel=0.29.0=py27_0
- zlib=1.2.8=3
- pip:
- python-dateutil==2.4.1
prefix: /Users/me/anaconda/envs/TestEnv
答案 0 :(得分:2)
我想也许你应该安装另一个版本的opencv。
试试这个:
conda search -c conda-forge opencv