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

sys.path


Is sys.path setup differnently in jython vs python? I have environment
variables pythonpath and jythonpath set to include C:\python22 but the
initial printout indicates it is being ignored. Also when I used
sys.path.extend, the added pathname shows up as a series of single
characters. Have I misused .extend?

Thanks,

jh

import sys
print sys.path
sys.path.extend("c:\python22")
print sys.path
import urllib

['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython']
['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython', 'c', ':', '\\', 'p',
'y', 't', 'h', 'o', 'n', '2', '2']
Traceback (innermost last):
File "<string>", line 9, in ?
ImportError: no module named urllib

May 8 '07 #1
3 3876
HMS Surprise wrote:
Have I misused .extend?
The .extend() method expects an iterable, try .append() instead.

Cheers,

--
Klaus Alexander Seistrup
http://klaus.seistrup.dk/
May 8 '07 #2
On May 8, 10:40 am, Klaus Alexander Seistrup <k...@seistrup.dkwrote:
HMS Surprise wrote:
Have I misused .extend?

The .extend() method expects an iterable, try .append() instead.

Cheers,

--
Klaus Alexander Seistruphttp://klaus.seistrup.dk/
Thanks Klaus.

That certainly cleaned up sys.path. Now if I can get the system to
search there for my lib file.

May 8 '07 #3
On May 9, 1:35 am, HMS Surprise <j...@datavoiceint.comwrote:
Is sys.path setup differnently in jython vs python? I have environment
variables pythonpath and jythonpath set to include C:\python22 but the
initial printout indicates it is being ignored. Also when I used
sys.path.extend, the added pathname shows up as a series of single
characters. Have I misused .extend?

Thanks,

jh

import sys
print sys.path
sys.path.extend("c:\python22")
print sys.path
import urllib

['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython']
Your sys.path looks stuffed already. You may have missed this in the
flurry of posts and counter-posts, but I asked: have you been messing
with the PYTHONHOME environment variable?

This is what sys.path looks like after a normal installation, before
any messing about:

C:\junk>set PYTHONPATH
Environment variable PYTHONPATH not defined

C:\junk>set PYTHONHOME
Environment variable PYTHONHOME not defined

C:\junk>\python22\python
Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>import sys
sys.path
['', 'C:\\junk', 'C:\\python22\\DLLs', 'C:\\python22\\lib', 'C:\
\python22\\lib\\lib-tk', 'C:\\python22', 'C:\\python22\\lib\\site-
packages']
>>>
To get urllib to be imported from c:\python22\lib\urllib.py, you need
c:\python22\lib (NOT c:\python22) to be in sys.path, and it should
ALREADY be in sys.path (if you are running Python 2.2, of course).

Please go to a dos-prompt, type in what I did above and paste the
results into your next post.
May 8 '07 #4

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

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
9
by: Bengt dePaulis | last post by:
I have a local directory that I want to include in my sys.path How to save it permanently? Regards /Bengt
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
4
by: python | last post by:
Bad file names, i.e. filenames the OS considers illegal, will cause functions in the os.path module to raise an error. Example: import os.path print os.path.getsize( 'c:/pytest/*.py' ) On...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
6
by: bukzor | last post by:
I have to go into these convulsions to get the directory that the script is in whenever I need to use relative paths. I was wondering if you guys have a better way: from os.path import dirname,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
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
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...
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...

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.