473,387 Members | 1,561 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,387 software developers and data experts.

PYTHONPATH problems

OK - I just checked Programming Python out from the library, and am
enjoying seeing the examples (I've dabbled in Python some previously, but
an trying to expand my knowledge a bit).

I'm having a problem getting the PYTHONPATH to work - I've got the
variable set in the shell (and exported), and it's showing up when I do
this:

-- Begin --
Python 2.2.2 (#2, Feb 5 2003, 10:40:08) [GCC 3.2.1 (Mandrake Linux 9.1
3.2.1-5mdk)] on linux-i386 Type "help", "copyright", "credits" or
"license" for more information.
import sys
print sys.path ['', '/home/tim/python/PP/Examples', '/usr/lib/python2.2',
'/usr/lib/python2.2/plat-linux-i386', '/usr/lib/python2.2/lib-tk',
'/usr/lib/python2.2/lib-dynload', '/usr/lib/python2.2/site-packages']

-- End --

However, it isn't finding any of the modules in the directory tree that
begins under /home/tim/python/PP/Examples (it's not having any problems
with the standard modules - as evidenced by the import of sys above).

I'm at a loss - any thoughts on what I'm doing incorrectly?

Thanks for any assistance!

Tim
Jul 18 '05 #1
4 2250
Tim Isakson wrote:
However, it isn't finding any of the modules in the directory tree
that
begins under /home/tim/python/PP/Examples (it's not having any
problems
with the standard modules - as evidenced by the import of sys above).


We'll need to see the files contained therein, what their permissions
are, and what their contents are. Do they have the right permissions?
Do they end in .py? Are you importing the module exactly as it is name
(less the .py extension)?

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \
\__/ Sometimes there's no point in giving up.
-- Louis Wu
Jul 18 '05 #2
Tim Isakson:
I'm having a problem getting the PYTHONPATH to work - I've got the
variable set in the shell (and exported), and it's showing up when I do
this:


So why do you think the problem has to do with PYTHONPATH? Perhaps there's
something wrong with your import statement, the name of the files, ...
Tell us more.

--
René Pijlman
Jul 18 '05 #3
Tim Isakson wrote:
However, it isn't finding any of the modules in the directory tree that
begins under /home/tim/python/PP/Examples (it's not having any problems
with the standard modules - as evidenced by the import of sys above).
"sys" is a built-in module; Python finds that one without even looking
at the path.
I'm at a loss - any thoughts on what I'm doing incorrectly?

Thanks for any assistance!


running Python with the "-vv" flag might provide you with some
additional clues:

$ python -vv
import mymodule

# trying mymodule.so
# trying mymodulemodule.so
# trying mymodule.py
# trying mymodule.pyc
# trying /mysystem/lib/python2.1/mymodule.so
# trying /mysystem/lib/python2.1/mymodulemodule.so
/.../
# trying /mysystem/lib/python2.1/site-packages/PIL/mymodule.py
# trying /mysystem/lib/python2.1/site-packages/PIL/mymodule.pyc
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named mymodule

(also note that you must have read access to the scripts; if Python
cannot read a file, it treats it as if it didn't exist)

</F>


Jul 18 '05 #4
On Thu, 20 Nov 2003 11:13:23 +0100, Fredrik Lundh wrote:
Tim Isakson wrote:
However, it isn't finding any of the modules in the directory tree that
begins under /home/tim/python/PP/Examples (it's not having any problems
with the standard modules - as evidenced by the import of sys above).


"sys" is a built-in module; Python finds that one without even looking at
the path.
I'm at a loss - any thoughts on what I'm doing incorrectly?

Thanks for any assistance!


running Python with the "-vv" flag might provide you with some additional
clues:

$ python -vv
>>> import mymodule

# trying mymodule.so
# trying mymodulemodule.so
# trying mymodule.py
# trying mymodule.pyc
# trying /mysystem/lib/python2.1/mymodule.so # trying
/mysystem/lib/python2.1/mymodulemodule.so /.../
# trying /mysystem/lib/python2.1/site-packages/PIL/mymodule.py #
trying /mysystem/lib/python2.1/site-packages/PIL/mymodule.pyc
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named mymodule

(also note that you must have read access to the scripts; if Python cannot
read a file, it treats it as if it didn't exist)

</F>


Thanks for the -vv flag tip - it helped some.

Sadly (for me, at least), the problem turned out to be user error - I was
using BASH syntax for the path while within Python, and needless to say,
that didn't do the trick.

Once I changed the imports to use '.' as the delimiter, things worked
fine.

Thanks for your assistance!

Tim
Jul 18 '05 #5

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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.