Ubuntu18.04 pip方法安装python-pcl(python2与python3均可)

Ubuntu18.04 pip方法安装python-pcl


ubuntu安装python-pcl有两种方法:源码编译、pip安装。源码编译比较麻烦,虽然我之前编译成功了,一旦环境有变,再次编译就很麻烦。这里就介绍怎么pip方法安装。
pip安装很简单,直接在python环境中执行下面语句,下载源设置为豆瓣的

pip install python-pcl -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

这个方法我也是参考网上别的博客,主要讲下碰到的问题与解决方案,在python3环境中没有碰到什么问题,直接就成功了,但是在python2环境中会遇到错误:

Collecting numpy!=1.16.2,>=1.16.1 (from python-pcl)
  Downloading http://pypi.doubanio.com/packages/ff/59/d3f6d46aa1fd220d020bdd61e76ca51f6548c6ad6d24ddb614f4037cf49d/numpy-1.17.4.zip (6.4MB)
    100% |████████████████████████████████| 6.4MB 12.3MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "", line 1, in <module>
      File "/tmp/pip-build-ta8J7Y/numpy/setup.py", line 31, in <module>
        raise RuntimeError("Python version >= 3.5 required.")
    RuntimeError: Python version >= 3.5 required.

其实这个错误原因很简单,python-pcl要求numpy版本>=1.16.1且!=1.16.2(好像是1.16.2版本有bug),我的环境中numpy版本比较低,pip就自动去网上下载numpy,但现在numpy最新版是1.17.4(我2019.12.3安装的时候),pip默认安装最新版numpy==1.17.4,但是1.17.4版本要求python版本>=3.5结果就导致了错误。
原因知道了,解决办法就很简单了,手动安装numpy为1.16.1即可:

pip install numpy==1.16.1

再次执行上面安装python-pcl的命令,成功

$ pip install python-pcl -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
Collecting python-pcl
  Downloading http://pypi.doubanio.com/packages/00/2e/11582d84f4a9326649517c7a4eb14ecf4a9eef07766fdfa24367c5a8af7a/python_pcl-0.3.0a1-cp27-cp27mu-manylinux1_x86_64.whl (16.9MB)
    100% |████████████████████████████████| 16.9MB 1.7MB/s 
Requirement already satisfied: filelock in /home/zhangqb/ProgramFiles/anaconda3/envs/python27/lib/python2.7/site-packages (from python-pcl)
Requirement already satisfied: numpy!=1.16.2,>=1.16.1 in /home/zhangqb/ProgramFiles/anaconda3/envs/python27/lib/python2.7/site-packages (from python-pcl)
Requirement already satisfied: Cython>=0.26.0 in /home/zhangqb/ProgramFiles/anaconda3/envs/python27/lib/python2.7/site-packages (from python-pcl)
Requirement already satisfied: nose in /home/zhangqb/ProgramFiles/anaconda3/envs/python27/lib/python2.7/site-packages (from python-pcl)
Installing collected packages: python-pcl
Successfully installed python-pcl-0.3.0a1

你可能感兴趣的:(python)