On ubuntu 18.04 LTS, Caffe-cpu can install by....
sudo apt-get install caffe-cpu
... but it fails when I import on python2. It can only import on python3.
How to import caffe on python2? I tried to find caffe path, and...
$python
>>>import sys
>>>sys.path.append("/~~~~") //~~~ means every path to find "find / -name caffe"
>>>exit()
$exit
$python
>>>import caffe
... This is what I tried to import caffe on python2.7.
How to import caffe on python2.7? Thanks.
Looking at the requirements for the
caffe-cpu
package (https://packages.ubuntu.com/bionic/caffe-cpu) we can see that this package actually calls inpython3-caffe-cpu
. This is the Python 3 only version of the package.I did some
apt
repository searches. There is no Python 2 version of this package available in Bionic. This is why you can't import it in Python 2 - it doesn't have a Python 2 pre-packaged version available for use.Also, keep in mind Python 2 support dies out in a year's time; you should really be using Python 3 for your projects and not Python 2.
I found that conda has better support
Multiple versions of python supported.