Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > C/C++ Import

Reply
Thread Tools

C/C++ Import

 
 
7H3LaughingMan
Guest
Posts: n/a
 
      02-08-2010
To make the background information short, I am trying to take a
program that uses Python for scripting and recompile it for Linux
since it originally was built to run on Win32. The program itself was
designed to be able to be compiled on Linux and someone made there on
release with source that added python scripting. After some issues I
got it to compile but now it is unable to import the files that it
needs.

The program is running the following code...
PyImport_Import( PyString_FromString("python.PlayerManager") );

This is meant to import the file PlayerManager.py inside of the python
folder. However it throws the following Python Error (Gotten through
PyErr_Print())
ImportError: No module named python.PlayerManager

I am using 2.6.4 so I can't call it by the filename, does anyone know
how to do a proper import?
 
Reply With Quote
 
 
 
 
Austin Bingham
Guest
Posts: n/a
 
      02-08-2010
Does the 'python' directory contain a file named '__init__.py'? This
is required to let that directory act as a package (see:
http://docs.python.org/tutorial/modules.html#packages); without it,
you'll see the symptoms you're seeing.

Austin

On Mon, Feb 8, 2010 at 4:56 AM, 7H3LaughingMan <(E-Mail Removed)> wrote:
> To make the background information short, I am trying to take a
> program that uses Python for scripting and recompile it for Linux
> since it originally was built to run on Win32. The program itself was
> designed to be able to be compiled on Linux and someone made there on
> release with source that added python scripting. After some issues I
> got it to compile but now it is unable to import the files that it
> needs.
>
> The program is running the following code...
> PyImport_Import( PyString_FromString("python.PlayerManager") );
>
> This is meant to import the file PlayerManager.py inside of the python
> folder. However it throws the following Python Error (Gotten through
> PyErr_Print())
> ImportError: No module named python.PlayerManager
>
> I am using 2.6.4 so I can't call it by the filename, does anyone know
> how to do a proper import?
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
 
 
 
7H3LaughingMan
Guest
Posts: n/a
 
      02-08-2010
The folder does contain a file named '__init__.py'. However it
contains nothing inside of the file.

On Feb 8, 12:42*am, Austin Bingham <(E-Mail Removed)> wrote:
> Does the 'python' directory contain a file named '__init__.py'? This
> is required to let that directory act as a package (see:http://docs.python.org/tutorial/modu...kages);without it,
> you'll see the symptoms you're seeing.
>
> Austin
>
> On Mon, Feb 8, 2010 at 4:56 AM, 7H3LaughingMan <(E-Mail Removed)> wrote:
> > To make the background information short, I am trying to take a
> > program that uses Python for scripting and recompile it for Linux
> > since it originally was built to run on Win32. The program itself was
> > designed to be able to be compiled on Linux and someone made there on
> > release with source that added python scripting. After some issues I
> > got it to compile but now it is unable to import the files that it
> > needs.

>
> > The program is running the following code...
> > PyImport_Import( PyString_FromString("python.PlayerManager") );

>
> > This is meant to import the file PlayerManager.py inside of the python
> > folder. However it throws the following Python Error (Gotten through
> > PyErr_Print())
> > ImportError: No module named python.PlayerManager

>
> > I am using 2.6.4 so I can't call it by the filename, does anyone know
> > how to do a proper import?
> > --
> >http://mail.python.org/mailman/listinfo/python-list

>
>


 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      02-08-2010
On 2/7/2010 10:56 PM, 7H3LaughingMan wrote:
> To make the background information short, I am trying to take a
> program that uses Python for scripting and recompile it for Linux
> since it originally was built to run on Win32. The program itself was
> designed to be able to be compiled on Linux and someone made there on
> release with source that added python scripting. After some issues I
> got it to compile but now it is unable to import the files that it
> needs.
>
> The program is running the following code...
> PyImport_Import( PyString_FromString("python.PlayerManager") );
>
> This is meant to import the file PlayerManager.py inside of the python
> folder. However it throws the following Python Error (Gotten through
> PyErr_Print())
> ImportError: No module named python.PlayerManager
>
> I am using 2.6.4 so I can't call it by the filename, does anyone know
> how to do a proper import?


Your 'python' package directory must be in a directory listed in
sys.path. I would print that check.

 
Reply With Quote
 
Austin Bingham
Guest
Posts: n/a
 
      02-09-2010
Just to elaborate on Terry's point a bit, sys.path is influenced (in
part) by the PYTHONPATH environment variable. If you find that the
directory containing 'python' is not in sys.path (which you can check
with 'import sys; print sys.path'), add that directory to PYTHONPATH
and try again. This may not be the solution you ultimately end up
using, but it'll get you pointed in the right direction.

Austin

On Mon, Feb 8, 2010 at 5:52 PM, Terry Reedy <(E-Mail Removed)> wrote:
> On 2/7/2010 10:56 PM, 7H3LaughingMan wrote:
>>
>> To make the background information short, I am trying to take a
>> program that uses Python for scripting and recompile it for Linux
>> since it originally was built to run on Win32. The program itself was
>> designed to be able to be compiled on Linux and someone made there on
>> release with source that added python scripting. After some issues I
>> got it to compile but now it is unable to import the files that it
>> needs.
>>
>> The program is running the following code...
>> PyImport_Import( PyString_FromString("python.PlayerManager") );
>>
>> This is meant to import the file PlayerManager.py inside of the python
>> folder. However it throws the following Python Error (Gotten through
>> PyErr_Print())
>> ImportError: No module named python.PlayerManager
>>
>> I am using 2.6.4 so I can't call it by the filename, does anyone know
>> how to do a proper import?

>
> Your 'python' package directory must be in a directory listed in sys.path. I
> would print that check.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
to use import java.lang.* or import java.lang.Math or none at all? JPractitioner Java 13 02-24-2006 08:48 PM
XML Schema question - does "import" import elements? Vitali Gontsharuk XML 2 08-25-2005 07:33 PM
IMPORT STATIC; Why is "import static" file scope? Why not class scope? Paul Opal Java 12 10-10-2004 11:01 PM
GTK import doesn't import first time Dennis Python 2 08-18-2003 10:00 PM
import/from import question Artur M. Piwko Python 1 07-02-2003 07:04 PM



Advertisments