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

Python code runs from IDE, but not from terminal

My imports don't work when I try to run the code from Linux terminal. Specifically, imports from other packages in the same project. I know this is a PYTHONPATH issue, but I don't know how to diagnose it further or solve it. The code runs fine…
Baron Yugovich
  • 3,843
  • 12
  • 48
  • 76
8
votes
2 answers

Provide temporary PYTHONPATH on the commandline?

I'm thinking of something like python3 my_script.py --pythonpath /path/to/some/necessary/modules Is there something like this? I know (I think) that Pycharm temporarily modifies PYTHONPATH when you use it to execute scripts; how does Pycharm do…
Ray
  • 7,833
  • 13
  • 57
  • 91
8
votes
3 answers

"RuntimeError: working outside of application context" when unit testing with py.test

I'm trying to migrate to py.test for the ease of use and auto-discovery of tests. When I run my tests with unittest, the test works fine. When I run the test under py.test, I get RuntimeError: working outside of application context. Here's the…
John Hazen
  • 1,296
  • 1
  • 8
  • 19
8
votes
2 answers

PYTHONPATH showing empty in ubuntu 13.04

when i do echo $PYTHONPATH it returns nothing..empty line. so what does that mean. Im using python and it's working fine ..so whats the use of pythonpath and what should be the value of this in ubuntu 13.04 /usr/bin/ or /usr/lib/ ..or something…
8
votes
1 answer

Is there a better way to control the PYTHONPATH of a subprocess?

I have a set of scripts that has to modify os.sys.path on the fly. The scripts then kick off a subprocess. Ideally, the subprocess would have the same os.sys.path as the caller. I want to avoid passing it in as an argument, since that would…
Miebster
  • 2,365
  • 4
  • 21
  • 27
8
votes
1 answer

Upgrade version of scikit-learn included in Enthought Canopy distribution

I have EPD 7.3.1 installed (nowadays called Enthought Canopy), which comes with scikit-learn v 0.11. I am running Ubuntu 12.04. I need to install v 0.12 of scikit-learn. The scikit-learn doc says clone the repository, add the scikit-learn directory…
scharfmn
  • 3,561
  • 7
  • 38
  • 53
7
votes
2 answers

pythonic module organization - how to refer to files in root directory?

I have my python code in a folder called "project", so my code files are in project/*.py. I want to have submodules within it, e.g. project/code.py # where code lives project/mymodule1 # where more code lives project/mymodule2 each module…
user248237
7
votes
2 answers

which python vs PYTHONPATH

If I type in which python I get: /home/USER/anaconda3/bin/python If I type in echo $PYTHONPATH I get: /home/USER/terrain_planning/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages Should that not be the same? And is it…
gab
  • 157
  • 2
  • 9
7
votes
5 answers

Use __init__.py to modify sys path is a good idea?

I want to ask you something that came to my mind doing some stuff. I have the following structure: src - __init__.py - class1.py + folder2 - __init__.py - class2.py I class2.py I want to import class1 to use it.…
Solar
  • 445
  • 1
  • 4
  • 12
7
votes
3 answers

How to install python modules in a local directory? --user and exporting pythonpath isn't working

I don't know very much about python but would like to install some python modules in a local directory on a server on which I don't have sudo access. I start by going into my desired directory (not root) and create the directory tree needed to store…
jake9115
  • 3,964
  • 12
  • 49
  • 78
7
votes
3 answers

Why does virtualenv inherit $PYTHONPATH from my shell?

So I'm migrating all my tools from python2 to python3.4 on an Ubuntu 14.04 machine. So far I've done the following: aliased python to python3 in my zshrc for just my user installed pip3 on the system itself (but I'll just be using virtualenvs for…
brianclements
  • 879
  • 2
  • 8
  • 14
7
votes
1 answer

python, change user site directory or install setup.py --prefix with --user

I'd want to install python modules as non-root user like this $ pip install -I --install-option="--prefix=~/usr" scipy Unfortunately this usually does not work unless you specify --user. But --user can't be used together with --prefix. Using --user…
rudimeier
  • 854
  • 1
  • 8
  • 20
7
votes
3 answers

Setting up pythonpath in OS X

A new PHP developer here trying to learn Python/Django using the "Tango With Django" tutorial. I'm up to section 2.2.2 where I have to set up the pythonpath and I'm having the following problem: When I type the following in the terminal: echo…
Jean-Luc Neptune
  • 93
  • 1
  • 2
  • 9
7
votes
1 answer

using pip to install packages locally in spite of satisfied global requirements

I am trying to use pip to install a package locally in ~/.local. The problem is that the package (in an older version) is already available globally on the system. Even though the global python packages directory is not in my PYTHONPATH, pip still…
user248237
7
votes
3 answers

How to flexibly change PYTHONPATH

To specify the classpath in Java, I use the -cp or -classpath option to java. What is the equivalent option in Python? I know I can set the OS variable PYTHONPATH but there shouldn't be one PYTHONPATH to rule them all. I sometimes use PyDev in…
Paul Draper
  • 78,542
  • 46
  • 206
  • 285