error import module ptools

Asked by Francisco García

Hi,

I am trying to install Ptools on Ubuntu 12.04, using Python 2.4 with pythonbrew.

Installation of py++ and pygccxml is fine. The first step of building the libtools.a is fine. Now the problem starts when I run python interface.py or 'make testpython'

I make 'make testpython' or 'python interface.py', but ptools module does not load, which can be happening? thanks in advance.

The error is the follow:

fran@fran-laptop:~/soft/ptools-1.0.4c/Tests$ make testpython
echo "running python tests"
running python tests
python unittest1.py
Traceback (most recent call last):
  File "unittest1.py", line 1, in ?
    from ptools import *
  File "/home/fran/soft/ptools-1.0.4c/Tests/ptools.py", line 1, in ?
    from _ptools import *
ImportError: No module named _ptools
make: *** [testpython] Error 1

Question information

Language:
English Edit question
Status:
Solved
For:
PTools Edit question
Assignee:
No assignee Edit question
Solved by:
Francisco García
Solved:
Last query:
Last reply:
Revision history for this message
Adrien Saladin (adrien-saladin) said :
#1

Hi Francisco,

Please note that we have migrated PTools to github, the version of the library your are trying to compile is quite old.

Concerning your problem you may have forgotten to compile the shared library after generating the python bindings (with python interface.py).

Can you try to simply type "scons" in the ptools directory to generate the needed "_ptools.so" file?

Kind regards,
Adrien

Revision history for this message
Francisco García (fjav-garcia) said :
#2

Hi Adrien,

I had forgotten to do "scons", was only trying to "scons cpp" therefore was not generated _ptools.so.

Now when i run the scons command finally I obtain the following error:

/usr/bin/ld: cannot find-lpython2.4

I have python installed in the path /home/fran/.pythonbrew/pythons/Python-2.4.6

what should i do?

thanks

PD: now i use the new version ptools master of github

Revision history for this message
Francisco García (fjav-garcia) said :
#3

I solved the above problem by installing the python2.4-dev library, but still can not run Ptools

I try to load a sample script using Ptools but i get the following error:

fran@fran-laptop:~/soft/ptools-master$ python example.py
Traceback (most recent call last):
  File "example.py", line 1, in ?
    from ptools import * # cargar libreria ptools
  File "ptools.py", line 1, in ?
    from _ptools import *
ImportError: /usr/lib/libboost_python-py27.so.1.46.1: undefined symbol: Py_InitModule4_64

My _ptools.so file contains:

fran@fran-laptop:~/soft/ptools-master$ ldd _ptools.so
 linux-vdso.so.1 => (0x00007fff421fe000)
 libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007f0cdf746000)
 libpython2.4.so.1.0 => /usr/lib/libpython2.4.so.1.0 (0x00007f0cdf35d000)
 libboost_python-py27.so.1.46.1 => /usr/lib/libboost_python-py27.so.1.46.1 (0x00007f0cdf110000)
 libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0cdee10000)
 libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0cdeb14000)
 libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0cde8fd000)
 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0cde53e000)
 libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f0cde308000)
 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0cde0ea000)
 libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0cddee6000)
 libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f0cddce3000)
 /lib64/ld-linux-x86-64.so.2 (0x00007f0cdfd9b000)

is correct?

kind regards

Revision history for this message
Adrien Saladin (adrien-saladin) said :
#4

Hi Francisco,

From what I see there is a version mismatch with Python-dev and boost.Python: you are using python-dev for python2.4 and boost-python for 2.7.

This can be fixed easily but the master branch is rather old now. I recommend you to switch to the 'develop' branch (git checkout develop). In this branch a few bugs were corrected, all tests passes and we use this version in production within my lab. It corresponds to the next soon-to-be-released stable version.

The method to build the python module changed. I have just updated the tutorial accordingly.
Basically you don't need Boost.Python any more but Cython 0.16+ instead. And probably the "f2c" package instead of the Fortran compiler.

Compile with "python setup.py build".

Then make sure that a symbolic link pointing to build/lib.linux-????/_ptools.so is present in the Tests/ and PyAttract/ directories (or set the PYTHONPATH variable accordingly).

Best regards,

Revision history for this message
Francisco García (fjav-garcia) said :
#5

Hi Adrien,

I tried to install the version of Ptools Develop with Python 2.7 and working properly using the new version of the tutorial, thank you very much for your help.

I have seen that in the version develop, the file ptools.py, line 2 is incorrect, replace _ptools by ptools.

Regards.