Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C/C++ Import

2 views
Skip to first unread message

7H3LaughingMan

unread,
Feb 7, 2010, 10:56:39 PM2/7/10
to
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?

Austin Bingham

unread,
Feb 8, 2010, 1:42:24 AM2/8/10
to 7H3LaughingMan, pytho...@python.org
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

> --
> http://mail.python.org/mailman/listinfo/python-list
>

7H3LaughingMan

unread,
Feb 8, 2010, 9:50:20 AM2/8/10
to
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 <austin.bing...@gmail.com> 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/modules.html#packages);without it,
> you'll see the symptoms you're seeing.
>
> Austin
>

Terry Reedy

unread,
Feb 8, 2010, 11:52:17 AM2/8/10
to pytho...@python.org

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

Austin Bingham

unread,
Feb 9, 2010, 2:39:49 AM2/9/10
to pytho...@python.org
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 <tjr...@udel.edu> wrote:
> On 2/7/2010 10:56 PM, 7H3LaughingMan wrote:
>>

> 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
>

0 new messages