pythonpath

Eclipse/PyDev: Sync System PYTHONPATH runs continuously

Eclipse/PyDev: Sync System PYTHONPATH runs continuously Question: When Eclipse/PyDev is open I see an operation running in the background, over and over (as if stuck in an infinite loop), in the lower right status area telling me “Sync System PYTHONPATH (100%)”. I have a single Python interpreter configured, everything runs fine, but I wonder if …

Total answers: 1

Why does virtualenv inherit $PYTHONPATH from my shell?

Why does virtualenv inherit $PYTHONPATH from my shell? Question: 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 everything …

Total answers: 3

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

python – os.getenv and os.environ don't see environment variables of my bash shell Question: 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” ]’ …

Total answers: 3

PYTHONPATH on Linux

PYTHONPATH on Linux Question: 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 installed explicitly? Where is the …

Total answers: 3

Python: sharing common code among a family of scripts

Python: sharing common code among a family of scripts Question: 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 | | | |- script2.main.py | |- script2.matcher.py | …

Total answers: 3

How to get the PYTHONPATH in shell?

How to get the PYTHONPATH in shell? Question: 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 >>> sys.path [”, ‘/usr/local/lib/python2.7/dist-packages/feedparser-5.1.3-py2.7.egg’, ‘/usr/local/lib/python2.7/dist-packages/stripogram-1.5-py2.7.egg’, ‘/home/qiime/lib’, ‘/home/debian’, ‘/usr/lib/python2.7’, ‘/usr/lib/python2.7/plat-linux2’, ‘/usr/lib/python2.7/lib-tk’, ‘/usr/lib/python2.7/lib-old’, ‘/usr/lib/python2.7/lib- dynload’, ‘/usr/local/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages/PIL’, ‘/usr/lib/python2.7/dist-packages/gst-0.10’, ‘/usr/lib/python2.7/dist-packages/gtk-2.0’, …

Total answers: 6

adding directory to sys.path /PYTHONPATH

adding directory to sys.path /PYTHONPATH Question: I am trying to import a module from a particular directory. The problem is that if I use sys.path.append(mod_directory) to append the path and then open the python interpreter, the directory mod_directory gets added to the end of the list sys.path. If I export the PYTHONPATH variable before opening …

Total answers: 5

How does python find a module file if the import statement only contains the filename?

How does python find a module file if the import statement only contains the filename? Question: Everywhere I see Python code importing modules using import sys or import mymodule How does the interpreter find the correct file if no directory or path is provided? Asked By: Asciiom || Source Answers: Python has a path variable …

Total answers: 4

set pythonpath before import statements

set pythonpath before import statements Question: My code is: import scriptlib.abc import scriptlib.xyz def foo(): … some operations but the scriptlib is in some other directory, so I will have to include that directory in environment variable "PYTHONPATH". Is there anyway in which I can first add the scriptlib directory in environment variable "PYTHONPATH" before …

Total answers: 2

Why use sys.path.append(path) instead of sys.path.insert(1, path)?

Why use sys.path.append(path) instead of sys.path.insert(1, path)? Question: Edit: based on a Ulf Rompe’s comment, it is important you use “1” instead of “0”, otherwise you will break sys.path. I have been doing python for quite a while now (over a year), and I am always confused as to why people recommend you use sys.path.append() …

Total answers: 3