473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PYTHONPATH?

Several Documents about Python
refer to PYTHONPATH.
I could not find such variable.
(Python 2.4.2, IDLE 1.1.2, Windows XP)
How should/could I nominate a Directory to be
the local Directory?
Thanks for any guidance.
Feb 24 '06 #1
3 2185
Dr. Pastor wrote:
Several Documents about Python
refer to PYTHONPATH.
I could not find such variable.
(Python 2.4.2, IDLE 1.1.2, Windows XP)
How should/could I nominate a Directory to be
the local Directory?
Thanks for any guidance.


It's a so called environment-variable. You can set these in some obscure
windows dialog in the system-preferences on a per-system or per-user base.
Or you start using cygwin (lots of good other reasons for that), and do

export PYTHONPATH=/whatever

Diez
Feb 24 '06 #2
Dr. Pastor wrote:
Several Documents about Python refer to PYTHONPATH.
If you need to import libraries into Python, that don't reside in the
standard locations in your Python installation, you need to define
a PYTHONPATH environment variable in the operating system, which
points out this directory.

Defining this is done in the same way as defining PATH etc.
I could not find such variable.
Do you need it for anything?
(Python 2.4.2, IDLE 1.1.2, Windows XP)
How should/could I nominate a Directory to be the local Directory?


import os
os.chdir('c:/somedir')

Another way is to start python from there, e.g. from the
command prompt (nothing beats a command prompt!) you would do:

cd some\local\directory
python myscript.py (... or just python ...)

Note that backslash in a Python string literal denotes an escape
sequence. In Python 'c:\temp' means 'c' ':' tab 'e' 'm' 'p', since
'\t' is the escape sequence for a tab. You can use 'c:/temp' (ok
for Windows APIs) r'c:\temp' (r for raw string, i.e. don't use
escape sequences) or 'c:\\temp' (\\ is the escape sequence for
backslash).

Also note, that the way to use libraries from an arbitrary
directory without setting PYTHONPATH, is not with os.chdir,
but by doing this:

import sys
sys.path.append('c:/somedir')
Feb 24 '06 #3
Said obscure dialog is here:
My Computer > Properties > Advanced (tab) > Environment Variables

You probably want a new system variable.

You can check the value by starting a new terminal window and typing:

echo %PYTHONPATH%

Cheers
Tombo

Diez B. Roggisch wrote:
Dr. Pastor wrote:
Several Documents about Python
refer to PYTHONPATH.
I could not find such variable.
(Python 2.4.2, IDLE 1.1.2, Windows XP)
How should/could I nominate a Directory to be
the local Directory?
Thanks for any guidance.


It's a so called environment-variable. You can set these in some obscure
windows dialog in the system-preferences on a per-system or per-user base.
Or you start using cygwin (lots of good other reasons for that), and do

export PYTHONPATH=/whatever

Diez


Feb 24 '06 #4

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

Similar topics

0
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...
2
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...
4
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...
8
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...
3
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...
10
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...
0
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...
3
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...
4
by: mhearne808[insert-at-sign-here]gmail[insert-dot-he | last post by:
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...
1
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"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.