pgfoster / p4-phylogenetics

A Python phyloinformatic toolkit, and an implementation of tree-heterogeneous models of evolution
GNU General Public License v2.0
29 stars 8 forks source link

No module named pf #7

Open Kinggerm opened 7 years ago

Kinggerm commented 7 years ago

I use mac and pyenv. My global python version is 2.7.12. I tried to install p4 with sudo or in the home path, I got this:


  File "/Users/Kinggerm/.pyenv/versions/anaconda-4.0.0/bin/p4", line 86, in <module>
    from p4 import *
  File "p4/__init__.py", line 40, in <module>
    from . import func
  File "p4/func.py", line 21, in <module>
    from p4.alignment import Alignment
  File "p4/alignment.py", line 19, in <module>
    from p4.part import Part
  File "p4/part.py", line 3, in <module>
    import p4.pf as pf
ImportError: No module named pf'''
pgfoster commented 7 years ago

Kinggerm, it looks like for some reason the pf module was not built. It is a C-language extension module. To debug why, try building the module itself only, as

python setup.py build_ext -i

Note any error messages that fly by. The earliest error message is usually a clue. (Numpy API warning messages can be ignored)

Kinggerm commented 7 years ago

Oh, I see. Thank you!

jbernot commented 4 years ago

I'm having the same import error as Kinggerm described. I'm using python 3.7 and a virtual environment on a Unix HPC. I was able to install and run successfully on my MacBook, but it takes my laptop 12+ hours to run p4 heterogeneity tests on my phylogenomic data sets, so I would like to install in on an HPC. When I run

python setup.py build_ext -i

The only warnings besides NumPy API warning are:

In file included from /GWSPH/home/jbernot/.conda/envs/p4_2/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:21:0,
                 from /GWSPH/home/jbernot/.conda/envs/p4_2/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from Pf/p4_model.h:2,
                 from Pf/p4_node.c:3:
/GWSPH/home/jbernot/.conda/envs/p4_2/lib/python3.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1463:1: warning: ‘_import_array’ defined but not used [-Wunused-function]
 _import_array(void)
 ^~~~~~~~~~~~~

After running python setup.py build_ext -i when I try to import p4, I do not receive the pf module error and it appears to install. But when I

import p4
p4 --help

I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: bad operand type for unary -: '_Helper'

I'm stuck, any suggestions would be very much appreciated!

pgfoster commented 4 years ago

jbernot --- Confusingly, p4 is the name of the Python package, and it is also the name of a script that I like to use that I provide with the package (bin/p4 in the p4 package). That script is run from your shell, not from within Python. I put it in my path to make it easy to use. So you would run "p4 --help" from your bash or zsh prompt, not from within interactive Python.

You don't need to use the p4 script, and it is more "pythonic" to do the usual "import p4" from within Python rather than using the p4 script, but I am in the habit of using the script, and so I provide it.

The warning you quoted appears to have come from numpy. I think that can be ignored.

jbernot commented 4 years ago

Oh that makes sense! My installation is working now on the HPC -- thank you pgfoster!