Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2007, 6:43 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Hacking Around With Module Imports

Sorry about all these questions, but there's really very little resources on the Internet for such obscure things as these... I'm pretty helpless again.

Here goes:

I'm running some Python CGI scripts on a virtual server, which I don't have total control over. It has Python 2.4 installed, but it does not have MySQLdb installed.

Since the Python directory has limited write permission, I can not install modules on the server's Python.

I managed to hack around this by simply placing the contents of the folder "MySQLdb" in the same directory as the script I'm running.

However, the next problem is my script needs "setuptools", another Python module, installed. But this is where the problem arises.

I try the same method: put the source files in the same folder as the script. However, in one of the files of "setuptools" I get this error:

__file__ = pkg_resources.resource_filename(__name__,'_mysql.pyd')

del __bootstrap__, __loader__

NameError: global name '__loader__' is not defined

Which is apparently the error for when setuptools is not properly installed.

I tried a different method: install it locally, go into lib/site-packages/setuptools-0.6c7-py2.4.egg, and place that in the same directory as the CGI scripts. However, still the same error.

Is there any other way I could fake an install of a module without installing it directly to the Python 2.4 folder? I need a way to use the "pkg_resources.py" file from setuptools in my CGI script...
Sane is offline   Reply With Quote
Old Nov 29th, 2007, 10:04 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Re: Hacking Around With Module Imports

Have you tried putting the setuptools egg in a directory, and then appending the directory's path to sys.path ?
Arevos is offline   Reply With Quote
Old Nov 29th, 2007, 2:54 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Hacking Around With Module Imports

Thanks. I've tried that now, but I still get the same error.

I know what I did wrong now... when I built setuptools, it was built for win32. The server is Linux. I'll need to build it from source on my Linux machine at work, then try uploading it from there.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rule 3. Hacking Intel17 Community Announcements and Feedback 3 Jun 8th, 2006 4:05 PM
Update a Module Dietrich Python 2 Apr 29th, 2006 1:19 PM
Hacking. BadBit Coder's Corner Lounge 63 Nov 8th, 2005 2:58 AM
cgi module index.py?var=x how do i retrieve this w/o os module cypherkronis Python 1 Jul 3rd, 2005 1:10 PM
Build a Speech recognition module bingoelzouhery C# 2 May 24th, 2005 1:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC