473,738 Members | 3,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PYTHONPATH on OS X

I'm missing something major here. I'm trying to add a directory to my
python path using the PYTHONPATH environment variable, and it's being
ignored by the Python interactive shell.

Below is a capture of what I did. Note that my newfolder appears
nowhere on the list of directories in sys.path. How do I get Python
to pay attention to my shell variables?

Using bash on OS X 10.4.10.

%:~ user$ echo $PYTHONPATH

%:~ user$ PYTHONPATH=/Users/user/newfolder
%:~ user$ echo $PYTHONPATH
/Users/user/newfolder
%:~ user$ python
Python 2.5.1 (r251:54863, Aug 10 2007, 10:46:58)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
>>import sys
sys.path
['', '/usr/local/lib/python2.5/site-packages/
setuptools-0.7a1dev_r56320-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/ipython1-0.9alpha2-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/SQLAlchemy-0.4.0beta5-py2.5.egg', '/usr/local/lib/python2.5/
site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/
local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/
local/lib/python2.5/plat-mac/lib-scriptpackages' , '/usr/local/lib/
python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/
lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
PIL']

Oct 10 '07 #1
4 6945
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com schrieb:
I'm missing something major here. I'm trying to add a directory to my
python path using the PYTHONPATH environment variable, and it's being
ignored by the Python interactive shell.

Below is a capture of what I did. Note that my newfolder appears
nowhere on the list of directories in sys.path. How do I get Python
to pay attention to my shell variables?

Using bash on OS X 10.4.10.

%:~ user$ echo $PYTHONPATH

%:~ user$ PYTHONPATH=/Users/user/newfolder
%:~ user$ echo $PYTHONPATH
/Users/user/newfolder
%:~ user$ python
Python 2.5.1 (r251:54863, Aug 10 2007, 10:46:58)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
>>>import sys
sys.path
['', '/usr/local/lib/python2.5/site-packages/
setuptools-0.7a1dev_r56320-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/ipython1-0.9alpha2-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/SQLAlchemy-0.4.0beta5-py2.5.egg', '/usr/local/lib/python2.5/
site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/
local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/
local/lib/python2.5/plat-mac/lib-scriptpackages' , '/usr/local/lib/
python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/
lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
PIL']
Use

export PYTHONPATH=....

to pass environment vars to subprocesses.

Basic unix shell knowledge :)

$ man bash
....
export -p
The supplied names are marked for automatic export to
the envi-
ronment of subsequently executed commands. If the -f
option is
given, the names refer to functions. If no names are
given, or
if the -p option is supplied, a list of all names
that are
exported in this shell is printed. The -n option
causes the
export property to be removed from the named variables.
export
returns an exit status of 0 unless an invalid option is
encoun-
tered, one of the names is not a valid shell variable
name, or
-f is supplied with a name that is not a function.

....
Diez
Oct 10 '07 #2
On Oct 10, 11:00 pm, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne...@gma il.comwrote:
I'm missing something major here. I'm trying to add a directory to my
python path using the PYTHONPATH environment variable, and it's being
ignored by the Python interactive shell.

Below is a capture of what I did. Note that my newfolder appears
nowhere on the list of directories in sys.path. How do I get Python
to pay attention to my shell variables?

Using bash on OS X 10.4.10.

%:~ user$ echo $PYTHONPATH

%:~ user$ PYTHONPATH=/Users/user/newfolder
%:~ user$ echo $PYTHONPATH
/Users/user/newfolder
%:~ user$ python
Python 2.5.1 (r251:54863, Aug 10 2007, 10:46:58)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.>>i mport sys
>sys.path

['', '/usr/local/lib/python2.5/site-packages/
setuptools-0.7a1dev_r56320-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/ipython1-0.9alpha2-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/SQLAlchemy-0.4.0beta5-py2.5.egg', '/usr/local/lib/python2.5/
site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/
local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/
local/lib/python2.5/plat-mac/lib-scriptpackages' , '/usr/local/lib/
python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/
lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
PIL']
Try
export PYTHONPATH=/Users/user/newfolder

Otherwise (without 'export') the variable is defined in the shell but
not passed on when you launch python.

Cheers,
Anthony

Oct 10 '07 #3
On Oct 11, 8:00 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne...@gma il.comwrote:
I'm missing something major here. I'm trying to add a directory to my
python path using the PYTHONPATH environment variable, and it's being
ignored by the Python interactive shell.

Below is a capture of what I did. Note that my newfolder appears
nowhere on the list of directories in sys.path. How do I get Python
to pay attention to my shell variables?

Using bash on OS X 10.4.10.

%:~ user$ echo $PYTHONPATH

%:~ user$ PYTHONPATH=/Users/user/newfolder
%:~ user$ echo $PYTHONPATH
/Users/user/newfolder
%:~ user$ python
Python 2.5.1 (r251:54863, Aug 10 2007, 10:46:58)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.>>i mport sys
>sys.path

['', '/usr/local/lib/python2.5/site-packages/
setuptools-0.7a1dev_r56320-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/ipython1-0.9alpha2-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/SQLAlchemy-0.4.0beta5-py2.5.egg', '/usr/local/lib/python2.5/
site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/
local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/
local/lib/python2.5/plat-mac/lib-scriptpackages' , '/usr/local/lib/
python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/
lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
PIL']
You need to export the environment variable.

export PYTHONPATH

Graham

Oct 10 '07 #4
On Oct 10, 4:59 pm, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
wrote:
On Oct 11, 8:00 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-

here]com" <mhearne...@gma il.comwrote:
I'm missing something major here. I'm trying to add a directory to my
python path using the PYTHONPATH environment variable, and it's being
ignored by the Python interactive shell.
Below is a capture of what I did. Note that my newfolder appears
nowhere on the list of directories in sys.path. How do I get Python
to pay attention to my shell variables?
Using bash on OS X 10.4.10.
%:~ user$ echo $PYTHONPATH
%:~ user$ PYTHONPATH=/Users/user/newfolder
%:~ user$ echo $PYTHONPATH
/Users/user/newfolder
%:~ user$ python
Python 2.5.1 (r251:54863, Aug 10 2007, 10:46:58)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.>>i mport sys
>>sys.path
['', '/usr/local/lib/python2.5/site-packages/
setuptools-0.7a1dev_r56320-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/ipython1-0.9alpha2-py2.5.egg', '/usr/local/lib/python2.5/site-
packages/SQLAlchemy-0.4.0beta5-py2.5.egg', '/usr/local/lib/python2.5/
site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/
local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/
local/lib/python2.5/plat-mac/lib-scriptpackages' , '/usr/local/lib/
python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/
lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
PIL']

You need to export the environment variable.

export PYTHONPATH

Graham
Thanks all - I'm recently back to using Unix (Mac) after 5 years of
being on a PC. I guess I thought export was just another way of doing
assignment. My bad.

--Mike

Oct 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1488
by: Rami A. Kishek | last post by:
Hi, I would really appreciate help on this from all ye Win-oriented people. I have been using python under Linux for quite a while, know little about windows. I just upgraded my Python on WinME machine from Python 1.5.2 to 2.2.3 (in a separate directory). Using the Pythowin Pythonpath browser, I edited the python path to add my scripts directories. Then I tried to import my scripts and they're not visible. I tried many things: -...
2
26073
by: Eric Wichterich | last post by:
Hello Pythonistas, I am trying to get certain (self-written) libraries imported into my scripts using statements like "from library import function.py". But they are not being found. I think that the pythonpath-variable must be expanded to the location
4
1781
by: r.e.s. | last post by:
I have no PYTHONPATH nor any other python-related environment variables, yet everything seems fine. (I'm using PythonWin with winxp.) As long as modules are loaded through PythonWin, is PYTHONPATH unnecessary? Or am I missing something?
8
3045
by: Tero Pihlajakoski | last post by:
Hi, I've been experimenting on embedding Python to a C software, and ran into a little problem with PYTHONPATH (I'm running on linux). Here's the deal: When trying to call PyImport_Import("xyz"), Python returns an error "No module named xyz". The problem _seems_ to be that I had no PYTHONPATH variable defined (though python-shell works ok regardless), since the following in bash helps:
3
1584
by: D Denholm | last post by:
I recently installed Python 2.2 on my WinXP box. I am having problems figuring out how to create the PYTHONPATH correctly. I went to the WinXP SystemProperties > Advanced > Environment Variables and created a System Variable called PYTHONPATH with the value: G:\Python22\lib\site-packages\Pythonwin;
10
6525
by: sushant.sirsikar | last post by:
Hi, I am using Linux env.I set the PYTHONPATH using import sys sys.path.append(----) But we i close python and start again i is not showing my new entry in PYTHONPATH. Can anyone help me to make my path persistant? Thanks
0
1756
by: Michael Yanowitz | last post by:
Hello: Someone on my team tried out installing my Python code and found that setting PYTHONPATH does not work, but setting PATH environment variable works the way PYTHONPATH should. Is that how it supposed to be, or is that a bug or feature? -----Original Message----- (parts deleted) Subject: question on Python for windows
3
1443
by: rh0dium | last post by:
Hi all, Can anyone help me out. I would like to have python automatically look in a path for modules similar to editing the PYTHONPATH but do it at compile time so every user doesn't have to do this.. Soo... I want to add /foo/bar to the PYTHONPATH build so I don't have to add it later on. Is there a way to do this?
1
1705
by: Aljosa Mohorovic | last post by:
i have a working MySQLdb module (/usr/lib/python2.4/site-packages/ MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems. "clean shell" after login: python -c "import MySQLdb" reports no errors if i export PYTHONPATH: export PYTHONPATH=/var/www/projects/uv_portal/portal python -c "import MySQLdb" reports no errors as in previous case
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.