Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2004, 05:06 PM
markb_1984 markb_1984 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 137 markb_1984 User rank is Corporal (100 - 500 Reputation Level)markb_1984 User rank is Corporal (100 - 500 Reputation Level)markb_1984 User rank is Corporal (100 - 500 Reputation Level)markb_1984 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 53 m 52 sec
Reputation Power: 9
sys.path problem

I'm writing a python script which needs to read a package from a directory currently not known by python. I've simply appended the path to the sys module, then called the module in question, but on running, the package fails to be found. Here's the code I'm using:

#!/usr/bin/python

import sys

sys.path.append('/home/csunix/extras')

import nltk #package located in above appended directory



Any ideas where I'm going wrong???

Reply With Quote
  #2  
Old December 1st, 2004, 04:52 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 8
Send a message via MSN to Grim Archon
Permissions could be the problem.

When you say package do you mean module as in nltk.py
or that nltk is a sub-directory of /home/csunix/extras conforming to the Python package format (it has a __init__.py file).

grim
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #3  
Old December 1st, 2004, 04:46 PM
markb_1984 markb_1984 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 137 markb_1984 User rank is Corporal (100 - 500 Reputation Level)markb_1984 User rank is Corporal (100 - 500 Reputation Level)markb_1984 User rank is Corporal (100 - 500 Reputation Level)markb_1984 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 53 m 52 sec
Reputation Power: 9
Sorted. I did not reference the correct sub-directory containing the _init_.py


Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > sys.path problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT