473,324 Members | 2,511 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,324 software developers and data experts.

import vs. subdirectory search

Some obscure import issues:

I'm running Python 2.3.4 from a CGI script on a shared hosting Linux system.
The CGI program is being executed from Apache, as "nobody". I have some
local modules installed in "~myname/lib/python"; these include
"MySQLdb" and "M2Crypto".

Since this is running as "nobody", I append

/home/myname/lib/python

to sys.path.

Within the CGI programs,

import MySQLdb # works fine
import M2Crypto # works fine
import SSL # "No module named SSL"

The problem is that SSL is in a subdirectory of the M2Crypto directory,
and that's not being searched. I can execute "import M2Crypto.SSL",
but that doesn't have the same effect; it puts SSL in a different
place in the namespace. I'm trying to avoid that; it causes obscure
aliasing problems.

On Python 2.4 under Windows 2000, importing from a subdirectory
appears to work. Is that a Python 2.3.4 thing, or a Linux thing,
or something else?

(The idea is to be able to run (mostly) the same Python code on Windows, for
test, and Linux, for production.)

John Nagle
Jan 18 '07 #1
2 2122
"John Nagle" <na***@animats.comescribió en el mensaje
news:45**************@animats.com...
I'm running Python 2.3.4 from a CGI script on a shared hosting Linux
system.
The CGI program is being executed from Apache, as "nobody". I have some
local modules installed in "~myname/lib/python"; these include
"MySQLdb" and "M2Crypto".

Since this is running as "nobody", I append

/home/myname/lib/python

to sys.path.

Within the CGI programs,

import MySQLdb # works fine
import M2Crypto # works fine
import SSL # "No module named SSL"

The problem is that SSL is in a subdirectory of the M2Crypto directory,
and that's not being searched.
And should *not* be searched, unless the importing module is itself in the
M2Crypto directory.
I can execute "import M2Crypto.SSL",
but that doesn't have the same effect; it puts SSL in a different
place in the namespace. I'm trying to avoid that; it causes obscure
aliasing problems.
You *could* do: from M2Crypto import SSL, but I think this is not your
problem.
On Python 2.4 under Windows 2000, importing from a subdirectory
appears to work. Is that a Python 2.3.4 thing, or a Linux thing,
or something else?
No, it should not work as you describe it. Either you have another SSL
module in another place, or sys.path includes the M2Crypto directory.
On your 2.4 Windows, try this:
import sys
import SSL
print SSL.__file__
print sys.path
and see what happens

Jan 18 '07 #2
John try this:

from M2Crypto import SSL

That should put your SSL module in the namespace as you want.

--gordy

Jan 18 '07 #3

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

Similar topics

3
by: AckbarJedi | last post by:
I'm trying to get a java program to use a GUI included with my textbook, Fundamentals of Java by Lambert and Osborne, called BreezySwing. The book indicates that to import the GUI you need to...
5
by: Colin Brown | last post by:
I have instances where Python 2.3.2 import both does not work or error. It can be demonstrated under Win2k and Linux by doing the following: 1. Create a subdirectory "abc" 2. In directory "abc"...
4
by: Matt Whiteley | last post by:
I have some python code in a directory called customModules and this sits under the main directory which contains a piece of server.py code. Under 2.1.x and 2.2.x, I did the following in server.py...
43
by: Dan Perl | last post by:
Here is a python feature that I would like: to be able to import modules from an archive like the jar files in Java. Maybe a regular tar file? Maybe a python specific file type, let's call it a...
3
by: Olivier Noblanc ATOUSOFT | last post by:
Hello, When i want to import a .py fire from another subdirectory i make import inc/setupxml but that make me an error message.
3
by: David Jackson | last post by:
Hi all, I'm a real beginner with python but have what I think is a simple question. I am writing some simple modules and would like to place them into a subdirectory. But then I cannot seem to...
0
by: =?Utf-8?B?Qm9ubmll?= | last post by:
I have a basic ASP / Index Server search page. I have a web site contained in a subdirectory in the root of a main web site. What I’m trying to do is force the search page in the subdirectory,...
0
by: =?Utf-8?B?bW9iaWxlbW9iaWxl?= | last post by:
Hi all. I have experience with C#/VB.NET and ASP Classic, but am very new to ASP.NET. I'm using ASP.NET 2.0 and am modifying a site. I copied the site files to a subdirectory to test and...
8
by: tow | last post by:
I have a python script (part of a django application, if it makes any difference) which is exhibiting the following behaviour: import my_module # succeeds imp.find_module("my_module") # fails,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.