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.

676 questions
64
votes
2 answers

How do I import a Python script from a sibling directory?

Here is the directory structure: parent_dir/ foo_dir/ foo.py bar_dir/ bar.py How do I import bar.py into foo.py?
Orcris
  • 2,455
  • 6
  • 21
  • 23
63
votes
5 answers

Add to python path mac os x

I thought import sys sys.path.append("/home/me/mydir") is appending a dir to my pythonpath if I print sys.path my dir is in there. Then I open a new command and it is not there anymore. But somehow Python cant import modules I saved in that…
MacPython
  • 17,031
  • 10
  • 38
  • 46
60
votes
3 answers

PYTHONPATH on Linux

I'm novice in this, and I have started learning Python, but I have some questions that I'm not be able to understand, What exactly is the PYTHONPATH (on Ubuntu)? Is it a folder? Is Python provided by default on Ubuntu, or does it have to be…
user2580401
  • 1,564
  • 8
  • 23
  • 30
60
votes
6 answers

How to get the PYTHONPATH in shell?

debian@debian:~$ echo $PYTHONPATH /home/qiime/lib/: debian@debian:~$ python Python 2.7.3 (default, Jan 2 2013, 16:53:07) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>>…
showkey
  • 449
  • 30
  • 101
  • 235
58
votes
2 answers

Effect of using sys.path.insert(0, path) and sys.path(append) when loading modules

I was recently having a problem with a python ImportError, where the module was found when running on my local computer but not found on the CI server. I solved this problem by swapping sys.path.append(path) in my script with sys.path.insert(0,…
Michael Barton
  • 6,832
  • 6
  • 30
  • 40
54
votes
12 answers

ERROR: virtualenvwrapper could not find virtualenv in your path

I'm trying to create a virtualenv with virtualenvwrapper, but when I use mkvirtualenv I get the following : ERROR: virtualenvwrapper could not find virtualenv in your path I assumed it was a PYTHONPATH problem. But if I do a pip show virtualenv I…
vmonteco
  • 10,994
  • 12
  • 43
  • 73
47
votes
4 answers

how to set different PYTHONPATH variables for python3 and python2 respectively

I want to add a specific library path only to python2. After adding export PYTHONPATH="/path/to/lib/" to my .bashrc, however, executing python3 gets the error: Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python…
Douglas Su
  • 2,923
  • 3
  • 23
  • 50
46
votes
2 answers

python - os.getenv and os.environ don't see environment variables of my bash shell

I am on ubuntu 13.04, bash, python2.7.4 The interpreter doesn't see variables I set. Here is an example: $ echo $A 5 $ python -c 'import os; print os.getenv( "A" )' None $ python -c 'import os; print os.environ[ "A" ]' Traceback (most recent call…
xealits
  • 3,314
  • 2
  • 23
  • 30
45
votes
7 answers

How to correctly set PYTHONPATH for Visual Studio Code

How do I correctly set up the $PYTHONPATH variable for my workspace in VisualStudio Code? Background Information I have installed two versions of GNURadio: GNURadio version 3.7.11 installed by the Linux Mint package manager in…
Zababa
  • 1,268
  • 1
  • 10
  • 20
34
votes
5 answers

Add directory to Python path in PyCharm?

I want to be able to use the paraview.simple library in PyCharm. I already have paraview installed in my computer. This package cannot be installed with pip and there are no .whl files as far as I can tell. The website docs recommend that the…
user32882
  • 3,135
  • 2
  • 20
  • 47
33
votes
4 answers

Best practice for reusing python code

I have write a python library app(which contains several *.py files). And several of my python projects need to reuse the code in the library app. What's the recommended best practice for reusing python code? Currently I have thought out three…
Tyler Long
  • 16,201
  • 9
  • 87
  • 75
33
votes
15 answers

No module named django but it is installed

I have two versions of python 2.7 and 3.4 and installed django through pip. it shows in ubuntu terminal: $ pip freeze Django==1.6.11 $ pip --version pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7) $ python Python 2.7.9 (default, Feb 3…
srk
  • 439
  • 1
  • 5
  • 16
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
  • 557
  • 1
  • 6
  • 10
29
votes
2 answers

Customize module search path (PYTHONPATH) via pipenv

I have a Python project consisting of a Jupyter notebook, several scripts in a bin directory and modules in a src directory, with dependencies in a Pipfile: myproject ├── myproject.ipynb ├── Pipfile ├── Pipfile.lock ├── bin │   ├── bar.py │   └──…
David Moles
  • 39,436
  • 24
  • 121
  • 210
27
votes
8 answers

Import Error: No module named django

I am using centos linux. I had python 2.6 with django and now i upgraded to python 2.7. Python 2.6 is located in /usr/lib/python2.6. Python 2.7 is located in /usr/local/lib/python2.7. They both have site-packages directory and they both contain…
yossi
  • 11,822
  • 27
  • 75
  • 110
1
2
3
45 46