The problem is simple:
Using bash, I want to add a directory to my PYTHONPATH for ease of script execution. Unfortunately, the directory I want to use has a : in it. So I try each of the following
export PYTHONPATH=${PYTHONPATH}:/home/shane/mywebsite.com:3344/ export PYTHONPATH=${PYTHONPATH}:/home/shane/mywebsite.com\:3344/ export PYTHONPATH=${PYTHONPATH}:'/home/shane/mywebsite.com:3344/'
None of these work. Every time, the path is created as two separate directories on the path in python. My question is, is it possible to do this for bash? If so, what’s the syntax required?
The problem is not with bash. It should be setting your environment variable correctly, complete with the
:character.The problem, instead, is with Python’s parsing of the
PYTHONPATHvariable. Following the example set by thePATHvariable, it seems there is no escape character at all, so there is no way to make it interpret the:as something other than a separator. You can see it for yourself in the Python interpreter source code.The only solution is, as several people already mentioned, to use a symlink or something else to allow you to give a colon-less name for your directories.