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