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 (see PYTHONHOME above). It is always appended to PYTHONPATH.

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

Answer from Nitin Venkatesh on askubuntu.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › pythonpath-environment-variable-in-python
PYTHONPATH Environment Variable in Python - GeeksforGeeks
January 9, 2026 - PYTHONPATH is an environment variable that tells Python where to look for modules and packages beyond the standard library and installed site-packages.
Discussions

python - PYTHONPATH on Linux - Stack Overflow
PYTHONPATH is an environment variable which you can set to add additional directories where python will look for modules and packages. More on stackoverflow.com
🌐 stackoverflow.com
python - Is `PYTHONPATH` really an environment variable? - Stack Overflow
A list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default. More on stackoverflow.com
🌐 stackoverflow.com
Adding Python Path to Environment Variables HELP!
I dont get your problem Just press "New" and add the path to the python binary? More on reddit.com
🌐 r/PythonLearning
10
7
September 18, 2024
What does PYTHONPATH=. do?
It sets the path where Python looks for modules to the current directory or the directory one level above current. Why are you running those commands? More on reddit.com
🌐 r/learnpython
7
2
January 20, 2017
People also ask

How do I add an environment variable in Pythonpath?
Following a few steps will allow you to add an environment variable: By setting the Pythonpath environment variable. By adding manually to the path in the file.  By using the os.environ module method.  Then you can also use the os.environ["key"] = "value" syntax to add a single environment variable.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
What is Pythonpath used for?
Pythonpath is an environment variable that is used to specify the location of Python libraries. It is typically used by developers to ensure that their code can find the required Python libraries when it is run.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
🌐
Python.org
discuss.python.org › python help
Usage of PYTHONPATH - Python Help - Discussions on Python.org
August 9, 2022 - The results of my research are as follows: I create the environement key ‘PYTHONPATH’ with the following values: C:\Program Files\Python\DLLs C:\Program Files\Python\Lib C:\Program Files\Python C:\Program Files\Python\Lib\site-packages ...
🌐
TutorialsPoint
tutorialspoint.com › article › What-is-PYTHONPATH-environment-variable-in-Python
What is PYTHONPATH environment variable in Python?
August 26, 2023 - In Python, PYTHONPATH is an environment variable that specifies additional directories where Python searches for modules during imports.
🌐
Redreamality
redreamality.com › blog › pythonpathvs-code
How to Set PYTHONPATH on Windows, Linux, macOS and VS Code
August 21, 2025 - PYTHONPATH is an environment variable that allows users to add extra directories to the list of paths that the Python interpreter searches for modules and packages. This is particularly useful during development when you need to import custom ...
🌐
Simplilearn
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
September 14, 2025 - Python path is an environment variable used to maintain directories of custom Python libraries. Learn how to set a python path variable on Windows and Mac now!
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Find elsewhere
Top answer
1 of 3
73
  1. PYTHONPATH is 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}/foo 
    

    Here I use the sh syntax. 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).

  2. 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.

  3. The folder where your modules live is dependent on PYTHONPATH and 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 command ls -- where does ls live? /usr/bin? /bin? 99% of the time, you don't need to care -- Just use ls and be happy that it lives somewhere on your PATH so the shell can find it.

  4. 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.

  5. Configure PYTHONPATH to include the directory where your module resides and python will be able to find your module.

2 of 3
46
  1. PYTHONPATH is an environment variable
  2. Yes (see https://unix.stackexchange.com/questions/24802/on-which-unix-distributions-is-python-installed-as-part-of-the-default-install)
  3. /usr/lib/python2.7 on Ubuntu
  4. 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).
  5. if you use pip or setuptools, then you don't need to set PYTHONPATH explicitly

If you look at the instructions for pyopengl, you'll see that they are consistent with points 4 and 5.

🌐
Liquid Web
liquidweb.com › home › help docs › server administration › windows server administration › adding python path to windows 10 or 11 path environment variable
Adding Python Path to Windows 10 or 11 PATH Environment Variable | Liquid Web
December 15, 2025 - Properly configure Python on your ... of the current directory.Windows Operating System environment variable specifies the location of Python libraries, allowing Python to be readily accessible from any location within your ...
🌐
Env
env.dev › home › environment variables › pythonpath
PYTHONPATH environment variable — env.dev
June 9, 2026 - PYTHONPATH: PYTHONPATH is a list of directories (colon-separated on Unix, semicolon on Windows) that the interpreter inserts into sys.path ahead of installed s…
🌐
YouTube
youtube.com › the code city
Add Python to Path Environment Variable - Windows 10 - YouTube
In this tutorial, we will show you the process of adding Python to the Path variable in Windows 11 or Windows 10. By adding Python to the Path variable, you ...
Published: May 24, 2023
Views: 30K
🌐
ExamSnap
examsnap.com › home › a guide to the python path environment variable
A Guide to the Python Path Environment Variable - ExamSnap
May 15, 2026 - PYTHONPATH is an environment variable recognized by the Python interpreter before it starts running any code. It holds a list of directory paths, each separated by a colon on Unix-based systems or a semicolon on Windows.
🌐
Reddit
reddit.com › r/pythonlearning › adding python path to environment variables help!
r/PythonLearning on Reddit: Adding Python Path to Environment Variables HELP!
September 18, 2024 -

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!

🌐
Benjamincongdon
benjamincongdon.me › blog › 2017 › 02 › 19 › A-Better-Way-to-Wrangle-Python-Environments
A Better Way to Wrangle Python Environments | Ben Congdon
August 22, 2026 - However, if your PYTHONPATH is cluttered with packages that are irrelevant to the project you’re working on, getting a consistently correct, lean requirements.txt is impossible. This is why you really should use virtual environments for all python projects.
🌐
Reddit
reddit.com › r/learnpython › what does pythonpath=. do?
r/learnpython on Reddit: What does PYTHONPATH=. do?
January 20, 2017 -

I've often times run these commands blindly: export PYTHONPATH=. or PYTHONPATH=.. but I don't understand what they're doing...?

Top answer
1 of 2
2
It sets the path where Python looks for modules to the current directory or the directory one level above current. Why are you running those commands?
2 of 2
1
export creates or changes an environment variable for the current session in your operating system. ctrl-f for that particular one here to see what it means/does/is: https://docs.python.org/3/using/cmdline.html "." and ".." are coming from the relative path tradition. "." means "current directory" and ".." means parent directory (of the current directory). There is also "~" (for linux) which means "home directory" (which expands to "/home/your_user_name"). You can find more information about that here: https://en.wikipedia.org/wiki/Path_(computing)#Absolute_and_relative_paths You should not need to set these yourself, in almost all cases. I would look into how pip and virtualenv are used. The former installs libraries where python would expect to find them. I usually use it as python -m pip install some_library The latter creates a virtual environment (inside a folder) and puts basic libraries in it. virtualenv venv/ # create the venv directory in the current directory and copy over basic python stuff, for linux virtual venv\ # same as above if using Windows source venv/bin/activate # for linux, activate that virtual environment venv\Scripts\activate.bin # same as above if using Windows which python # in linux, check where your default python is; first executable listed should be the one inside venv/ or something is wrong where python # same as above, if using windows python -m pip install some_library # installs library inside that virtual environment/directory pip freeze > requirements.txt # records which libraries are installed; would in turn be used to install those libraries in another system/computer your_favorite_ide your_code.py # start editing your code using your virtual environment (if you're using Emacs, look into Elpy instead of this part; other IDEs also have their own way of configuring where the virtual environment is)
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-set-python-environment-variable-pythonpath-on-linux
How to set Python environment variable PYTHONPATH on Linux?
March 24, 2026 - The PYTHONPATH environment variable tells Python where to look for modules and packages beyond the standard library.
🌐
YouTube
youtube.com › watch
How Do I Fix The Python PATH Environment Variable? - Python Code School - YouTube
How Do I Fix The Python PATH Environment Variable? Are you having trouble running Python commands from the command line? In this video, we'll guide you throu...
Published: November 11, 2025
🌐
Reddit
reddit.com › r/learnpython › path, os module, environment variables
r/learnpython on Reddit: Path, Os module, environment variables
August 4, 2024 -

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.

Top answer
1 of 4
4
When you run a process, that process will be under a certain "environment". What is this environ (using this as abbreviation)? I don't know in details but part of it is the folder from which you started the process and other part is a bunch of variables, which are called environment variables. Those variables are usually in uppercase, and their values are strings (always strings). They can be used to configure your program, and, your computer in general. From Python, they can be accessed and/or modified via os.environ , and the folder, mentioned previously, with os.getcwd (Get Current Working Directory) and os.chdir (Change Dir). Now, PATH is a special environment variable whose value is a (string representing a) list of directories that your computer will look at when trying to start a process by its name. For example, if you type python, and then press Enter at a terminal, the computer will try to find a program named "python" at each directory present in PATH. If it finds one, it will execute it, if not, it will give an error like "Command 'python' not found". Note that there's also sys.path and PYTHONPATH, but those are Python concepts (and maybe inspired by the variable PATH).
2 of 4
2
The "environment" is a collection of data (always strings) that programms running on the system need to know to function properly. Their name is usually all uppercase. A typical example is what language to use to interact with the user, or the country and timezone the system is used in (in a multi-user system, this can be different per user, since there can be remote users). "Paths" are such variables, they are a list of directories to be searched in order to find specific files, when a file specification doesn't include a path. PATH contains a list of directories containing executable commands. DLLPATH (Windows) or LD_LIBRARY_PATH (Linux) list directories where dynaically loaded libraries can be retrieved In Python, os.environ is a dictionary of such data (where VARIABLE=value in the actual system environment is converted to a 'VARIABLE': 'value' dictionary entry. In practice you don't use them that much directly in code, but some Python APIs use them under the hood, for instance subprocess.Popen() will use the PATH if the command has no explicit path.