Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named pf #7

Open
Kinggerm opened this issue Feb 13, 2017 · 5 comments
Open

No module named pf #7

Kinggerm opened this issue Feb 13, 2017 · 5 comments

Comments

@Kinggerm
Copy link

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
Copy link
Owner

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
Copy link
Author

Oh, I see. Thank you!

@jbernot
Copy link

jbernot commented Aug 11, 2020

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
Copy link
Owner

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

jbernot commented Aug 12, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants