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
30
votes
4 answers

Python: select one of multiple installed module versions

On my system, I have several modules installed multiple times. To give an example, numpy 1.6.1 is installed in the standard path at /usr/lib/python2.7/dist-packages, and I have an updated version of numpy 1.8.0 installed at…
Jenny
  • 527
  • 1
  • 6
  • 11
30
votes
3 answers

Python: sharing common code among a family of scripts

I'm writing a family of Python scripts within a project; each script is within a subdirectory of the project, like so: projectroot | |- subproject1 | | | |- script1.main.py | `- script1.merger.py | |- subproject2 | | | …
Ray Toal
  • 86,166
  • 18
  • 182
  • 232
27
votes
1 answer

Import parent directory for brief tests

I have searched this site top to bottom yet have not found a single way to actually accomplish what I want in Python3x. This is a simple toy app so I figured I could write some simple test cases in asserts and call it a day. It does generate reports…
Rig
  • 1,276
  • 3
  • 22
  • 43
26
votes
6 answers

PYTHONPATH not working for sudo on GNU/Linux (works for root)

EDIT: Works for root, sudo is the problem. Read below. I have a directory with my own libraries, e.g. my Python libraries are located at /home/name/lib/py. I've added this directory to Python's PATH for all users (including root) by adding the…
usr
  • 695
  • 1
  • 5
  • 14
26
votes
2 answers

How to add something to PYTHONPATH?

I downloaded a package (called pysolr 2.0.15) to my computer to be used with Haystack. The instructions asks me to add pysolr to my PYTHONPATH. What exactly does that mean? After extracting the pysolr files, I ran the command python setup.py install…
goelv
  • 2,774
  • 11
  • 32
  • 40
25
votes
1 answer

What to set `SPARK_HOME` to?

Installed apache-maven-3.3.3, scala 2.11.6, then ran: $ git clone git://github.com/apache/spark.git -b branch-1.4 $ cd spark $ build/mvn -DskipTests clean package Finally: $ git clone https://github.com/apache/incubator-zeppelin $ cd…
A T
  • 13,008
  • 21
  • 97
  • 158
25
votes
5 answers

Module name different than directory name?

Let's assume I have a python package called bestpackage. Convention dictates that bestpacakge would also be a directory on sys.path that contains an __init__.py to make the interpreter assume it can be imported from. Is there any way I can set a…
DeaconDesperado
  • 9,977
  • 9
  • 47
  • 77
23
votes
3 answers

Set PYTHONPATH for local Jupyter Notebook in VS Code

I'm using Visual Studio 1.39.2 on Windows 10. I'm very happy that you can run Jupyter Notebook natively through VS Code as of October this year (2019), but one thing I don't get right is how to set my PYTHONPATH prior to booting up a local Jupyter…
Olov
  • 1,103
  • 11
  • 27
23
votes
3 answers

How to import multiple locations to PYTHONPATH (bash)

I know you can add multiple locations to python path by separating them by colons ie: export PYTHONPATH=~/one/location:~/second/location etc. I have several locations to add and it looks messy using the above method. Is there a way of adding them…
Anake
  • 7,201
  • 12
  • 45
  • 59
22
votes
2 answers

Creating a secondary site-packages directory (and loading packages from .pth files therein)

I would like to install some packages into a third-party site-packages directory (beyond the standard system locations). Is there any way to set this up such that .pth files therein are respected? Background: I'm using OS X, virtualenv, and…
mbauman
  • 30,958
  • 4
  • 88
  • 123
20
votes
3 answers

Why does heroku local:run wants to use the global python installation instead of the currently activated virtual env?

Using Heroku to deploy our Django application, everything seems to work by the spec, except the heroku local:run command. We oftentimes need to run commands through Django's manage.py file. Running them on the remote, as one-off dynos, works…
Ad N
  • 7,930
  • 6
  • 36
  • 80
20
votes
3 answers

pip won't install Python packages locally with --user

I'm trying to install packages locally with pip. It used to work with --user but now when I try it, it finds the version of the package in /usr/local/lib/ and then does not install it locally. Normally it would install things in ~/.local but now it…
user248237
19
votes
7 answers

How to properly structure internal scripts in a Python project?

Consider the following Python project skeleton: proj/ ├── foo │   └── __init__.py ├── README.md └── scripts └── run.py In this case foo holds the main project files, for example # foo/__init__.py class Foo(): def run(self): …
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
16
votes
3 answers

Force import module from Python standard library instead of PYTHONPATH default

I have a custom module in one of the directories in my PYTHONPATH with the same name as one of the standard library modules, so that when I import module_name, that module gets loaded. If I want to use the original standard library module, is there…
jrdioko
  • 32,230
  • 28
  • 81
  • 120
16
votes
5 answers

permanently remove directory from python path

I recently added some things to my python path that I don't want there using: export PYTHONPATH=$PYTHONPATH:/my/path You can use sys.path.remove to remove something in the path, but it's not 100% permanent like the way I added it with the command…
Ryan Saxe
  • 17,123
  • 23
  • 80
  • 128
1 2
3
50 51