0

I am using caffe with python on ubuntu 16.04 now, after compiling and installing, I need to add the directory of caffe to the PYTHONPATH variable in order that python knows how to find it when importing. But strange things happen here. I added the following line in ~/.bashrc: export PYTHONPATH="~/caffe/python/:$PYTHONPATH"

No need to mention, I encountered the problem that importing caffe failed, and I tried to find out why. Here is what I did in python:

>>>import sys

>>>sys.path

['','/home/roof/~/caffe/python',…………………]

Bash or python is adding a prefix /home/roof/ to the PYTHONPATH variable I set, which is unexpected, but why? How can I get rid of it?

Jerry Yang
  • 509
  • 4
  • 11

1 Answers1

3

Stop quoting the tilde, since that interferes with expansion.

$ FOO="~" bash -c 'echo $FOO'
~
$ FOO=~ bash -c 'echo $FOO'
/home/XXXXXX
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358