error import module ptools

Asked by Francisco García on 2013-10-25


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 or 'make testpython'

I make 'make testpython' or 'python', 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
Traceback (most recent call last):
  File "", line 1, in ?
    from ptools import *
  File "/home/fran/soft/ptools-1.0.4c/Tests/", line 1, in ?
    from _ptools import *
ImportError: No module named _ptools
make: *** [testpython] Error 1

Question information

English Edit question
PTools Edit question
No assignee Edit question
Solved by:
Francisco García
Last query:
Last reply:

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

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

Kind regards,

Hi Adrien,

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

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?


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

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
Traceback (most recent call last):
  File "", line 1, in ?
    from ptools import * # cargar libreria ptools
  File "", line 1, in ?
    from _ptools import *
ImportError: /usr/lib/ undefined symbol: Py_InitModule4_64

My file contains:

fran@fran-laptop:~/soft/ptools-master$ ldd => (0x00007fff421fe000) => /usr/lib/x86_64-linux-gnu/ (0x00007f0cdf746000) => /usr/lib/ (0x00007f0cdf35d000) => /usr/lib/ (0x00007f0cdf110000) => /usr/lib/x86_64-linux-gnu/ (0x00007f0cdee10000) => /lib/x86_64-linux-gnu/ (0x00007f0cdeb14000) => /lib/x86_64-linux-gnu/ (0x00007f0cde8fd000) => /lib/x86_64-linux-gnu/ (0x00007f0cde53e000) => /usr/lib/x86_64-linux-gnu/ (0x00007f0cde308000) => /lib/x86_64-linux-gnu/ (0x00007f0cde0ea000) => /lib/x86_64-linux-gnu/ (0x00007f0cddee6000) => /lib/x86_64-linux-gnu/ (0x00007f0cddce3000)
 /lib64/ (0x00007f0cdfd9b000)

is correct?

kind regards

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 build".

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

Best regards,

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, line 2 is incorrect, replace _ptools by ptools.