Questions tagged [pythonpath]

PYTHONPATH is an environment variable that can be used to augment the default search path for module imports in Python.

PYTHONPATH is an environment variable that can be used to augment the default search path for module files in Python. Values will be added to sys.path.

758 questions
7
votes
1 answer

Changing PYTHONPATH in shell

I'm a completely new user to Python and shell scripts, and have run into a dead end with this, even after Googling the issue and banging my head against the desk a lot. Any help is appreciated! I'm running Python 2.7.3 on a shell that I SSH into; I…
user2152303
  • 73
  • 1
  • 1
  • 4
7
votes
2 answers

How is the python module search path determined on Mac OS X?

When a non built-in module is imported, the interpreter searches in the locations given by sys.path. sys.path is initialized from these locations (http://docs.python.org/library/sys.html#sys.path): the directory containing the input script (or the…
christianbrodbeck
  • 2,113
  • 2
  • 19
  • 24
6
votes
2 answers

Can modules with a common package hierarchy mentioned multiple times in my PYTHONPATH?

I have two separate projects that share a package name. They run OK as long as they are not both on the PYTHONPATH, but as soon as they both appear one of them cannot find imports in its own project. Example, two projects like this: Project…
Simonz
  • 61
  • 2
6
votes
2 answers

How to set environment variables in vscode for debugging?

I have a fairly large python/c++ program that runs as follow: . set_env.sh -option A -option B python run.py The set_env.sh script modifies the PYTHONPATH and does all sort of export in order to point to the right c++ program. When running these…
6
votes
0 answers

Way working directory is added to sys.path differs between using `-c` or `-m`

If you launch a Python process either as a single command from the command line (with the -c flag) or by specifying a module path (with the -m flag), the working directory is prepended to sys.path. From the docs (emphases mine): -c…
Anakhand
  • 2,838
  • 1
  • 22
  • 50
6
votes
3 answers

Adding to PYTHONPATH in VS Code

I'm trying to add the src folder to my PYTHONPATH i.E. do the same thing as Mark directory as sources root in PyCharm. I've looked at the solutions to Visual Studio Code - How to add multiple paths to python path? but the solutions shown there do…
Hellvetia
  • 335
  • 3
  • 11
6
votes
2 answers

Modules paths in Python

I have created a folder with all my modules for my GAE application and with external libraries like Jinja2 to keep everything sorted in one place. I have folders structure like this: lib\ \utils\ \__init__.py \firepython \jinja2 …
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
6
votes
2 answers

Python Run Unittest as Package Import Error

I. Preface: The application directory structure and modules are listed at the end of the post. II. Statement of the Problem: If the PYTHONPATH is not set the application runs, but the unittest fails with the ImportError: No module named…
user3842449
6
votes
1 answer

django project directory structure and the python path

I am trying to get the best possible set up for developing my django project from the start and I'm having trouble getting everything to play nicely in the directory structure. I have set up virtualenv's (env in this example) so that I can deploy a…
Timmy O'Mahony
  • 53,000
  • 18
  • 155
  • 177
6
votes
4 answers

How to undo sys.path.append(pathToModule)

I have been trying to fix the python path on my cpu, and I originally was just trying to change my .bash_profile, but that wasn't working, so I used import sys sys.pat.append(path/To/Module) and now when I run my script, I get this error…
SUPhys
  • 221
  • 1
  • 5
  • 8
6
votes
2 answers

Cygwin equivalent of Linux /dev/sda, /dev/sdb etc

On Linux, I can access a hard drive as /dev/sdX. This ignores any partition tables, file systems, etc, and just accesses the drive block by block. What is the equivalent in Cygwin? I already searched Google, but could not find anything that…
rsteward
  • 1,146
  • 2
  • 8
  • 9
6
votes
1 answer

Why does PYTHONPATH with trailing colon add current directory to sys.path?

Consider a Python project like this: foo/ __init__.py scripts/ run.py demo.sh Under normal circumstances, attempting to import from the foo package will fail if you run the script from the root of the project, because default…
FMc
  • 41,963
  • 13
  • 79
  • 132
6
votes
2 answers

Split Python source into separate directories?

Here are some various Python packages my company "foo.com" uses: com.foo.bar.web com.foo.bar.lib com.foo.zig.web com.foo.zig.lib com.foo.zig.lib.lib1 com.foo.zig.lib.lib2 Here's the traditional way to store the source on disk: pysrc/ com/ …
dkamins
  • 21,450
  • 7
  • 55
  • 59
6
votes
2 answers

unable to add spark to PYTHONPATH

I am struggling to add spark to my python path: (myenv)me@me /home/me$ set SPARK_HOME="/home/me/spark-1.2.1-bin-hadoop2.4" (myenv)me@me /home/me$ set…
thecheech
  • 2,041
  • 3
  • 18
  • 25
6
votes
0 answers

Why is my Python 'sys.path' different for each tool I use to run my code?

I'm confused about the rules used to construct my Python sys.path. I understand that the fist entry will be "the directory containing the script that was used to invoke the Python interpreter", or an empty string if Python was invoked interactively,…
orome
  • 45,163
  • 57
  • 202
  • 418