Try appending to PYTHONPATH instead of overwriting it completely.
export PYTHONPATH=$PYTHONPATH:/home/dev/python-files
References:
According to the the Python documentation on PYTHONPATH
Augment the default search path for module files. [...]
The default search path is installation dependent, but generally begins with
prefix/lib/pythonversion(seePYTHONHOMEabove). It is always appended toPYTHONPATH.
meaning that some values exist in PYTHONPATH and the default search path is also only appended.
Additionally, this blog post (Archive.org link) also explains clearly why you need to append to PYTHONPATH and not overwrite it. Scrolling down to the section - Special cases and examining the search path explains it clearly (unfortunately no relative URL to that link so you'll have to scroll). Although the user gives the examples on a mac they are very much relevant to any platform
Try appending to PYTHONPATH instead of overwriting it completely.
export PYTHONPATH=$PYTHONPATH:/home/dev/python-files
References:
According to the the Python documentation on PYTHONPATH
Augment the default search path for module files. [...]
The default search path is installation dependent, but generally begins with
prefix/lib/pythonversion(seePYTHONHOMEabove). It is always appended toPYTHONPATH.
meaning that some values exist in PYTHONPATH and the default search path is also only appended.
Additionally, this blog post (Archive.org link) also explains clearly why you need to append to PYTHONPATH and not overwrite it. Scrolling down to the section - Special cases and examining the search path explains it clearly (unfortunately no relative URL to that link so you'll have to scroll). Although the user gives the examples on a mac they are very much relevant to any platform
You can also do as follows:
export PYTHONPATH=$(pwd)
or
export PYTHONPATH=${PWD}
pwd is the present working directory.
python - PYTHONPATH on Linux - Stack Overflow
python - Is `PYTHONPATH` really an environment variable? - Stack Overflow
Adding Python Path to Environment Variables HELP!
What does PYTHONPATH=. do?
Where is Pythonpath located?
How do I add an environment variable in Pythonpath?
What is Pythonpath used for?
PYTHONPATHis an environment variable which you can set to add additional directories where python will look for modules and packages. e.g.:# make python look in the foo subdirectory of your home directory for # modules and packages export PYTHONPATH=${PYTHONPATH}:${HOME}/fooHere I use the
shsyntax. For other shells (e.g.csh,tcsh), the syntax would be slightly different. To make it permanent, set the variable in your shell's init file (usually ~/.bashrc).Ubuntu comes with python already installed. There may be reasons for installing other (independent) python versions, but I've found that to be rarely necessary.
The folder where your modules live is dependent on
PYTHONPATHand where the directories were set up when python was installed. For the most part, the installed stuff you shouldn't care about where it lives -- Python knows where it is and it can find the modules. Sort of like issuing the commandls-- where doeslslive?/usr/bin?/bin? 99% of the time, you don't need to care -- Just uselsand be happy that it lives somewhere on yourPATHso the shell can find it.I'm not sure I understand the question. 3rd party modules usually come with install instructions. If you follow the instructions, python should be able to find the module and you shouldn't have to care about where it got installed.
Configure
PYTHONPATHto include the directory where your module resides and python will be able to find your module.
PYTHONPATHis an environment variable- Yes (see https://unix.stackexchange.com/questions/24802/on-which-unix-distributions-is-python-installed-as-part-of-the-default-install)
/usr/lib/python2.7on Ubuntu- you shouldn't install packages manually. Instead, use pip. When a package isn't in pip, it usually has a setuptools setup script which will install the package into the proper location (see point 3).
- if you use pip or setuptools, then you don't need to set
PYTHONPATHexplicitly
If you look at the instructions for pyopengl, you'll see that they are consistent with points 4 and 5.
Hey everyone. I’m an absolute beginner to computers, let alone python. I’m trying to add a python path to environment variable but when I try to edit the path, it takes me to a table-like screen. 1st pic is me selecting path and 2nd is the table. I’m following this tutorial online up until 1:20, where I’m getting a different screen than the uploader. I’ll try to link in another post under this, there’s only one attachment per post. Any help as to why that is, is greatly appreciated!
I've often times run these commands blindly: export PYTHONPATH=. or PYTHONPATH=.. but I don't understand what they're doing...?
hey everyone, I was having trouble understanding what path and environment variables exactly are!? Why are they used, and what are their purposes? it would be helpful if someone would clarify my doubts regarding this as I'm just starting with the Os module...Hey everyone, I'm having trouble understanding what path and environment variables are and why they are used. What is their purpose? It would be really helpful if someone could clarify my doubts regarding this, as I'm just starting with the Os module.