The version processing of python2.7&python3.5 based on Ubantu16.04 system

1, In general, the default version of Ubantu16.04 is Python2.7. When you install some libraries with pip, such as numpy and openCV, the default path of libraries is Python2.7. this is because the pip defaults to Python2.7 and pip3 is Python3.5 within Ubantu16.04.

If you want to modify ths default version, there are two ways can help you.

>>a:  set up a soft links

sudo update-alternatives --install /usr/bin/pip /usr/local/bin/pip3 100

>>b:  upgraded pip version

sudo apt-get install python3-pip
sudo pip3 install --upgrade pip
sudo apt-get remove python3-pip

and then, reopen a new terminal, you will get this result:

pip --version

Then, you can use pip directly when you installing the third-party packages of python3.5


2, Load environment variable

use this command and check your bashrc

vim ~/.bashrc

 and then, if there is no python path in this file, you should add the python path, like this:

sudo echo export PYTHONPATH="~/caffe/python" >> ~/.bashrc

This is about installing third-party packages of python.

 >>First, you need to find the path of requirements.txt. Check your caffe and you can find it under the /caffe/python, like this:

cd /caffe/python

cat requirements.txt

Cython>=0.19.2
numpy>=1.7.1
scipy>=0.13.2
scikit-image>=0.9.3
matplotlib>=1.3.1
ipython>=3.0.0
h5py>=2.2.0
leveldb>=0.191
networkx>=1.8.1
nose>=1.3.0
pandas>=0.12.0
python-dateutil>=1.4,<2
protobuf>=2.5.0
python-gflags>=2.0
pyyaml>=3.10
Pillow>=2.3.0
six>=1.1.0

And then, you can execute a perfect shell according to this file.

for req in $(cat requirements.txt); do sudo pip install $req; done

This install is ok, now you should enter into your python. but my python version is python3.5, so I just need to use python3 to get into python's library and import it's third-party packages.

python3

 now, let's install pandas package, you should run this command at the first, it can help you to check your python whether installed or not:

import pandas

or like this Error:

>>> import caffe Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named 'caffe'

This is because your numpy version is too high, just downgrade is ok. the following command can help you:

sudo pip uninstall numpy
sudo pip install numpy==1.14.5

This installation is complete.

 

 

If your installation is always going wrong, then:

sudo python3 -m pip install --upgrade --force-reinstall pip

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值