python-necpp icon indicating copy to clipboard operation
python-necpp copied to clipboard

ModuleNotFoundError: No module named 'PyNEC'

Open jdh4 opened this issue 4 years ago • 12 comments

I am on RHEL7. The shared library buids successfully but when I try to do "from PyNEC import *" it produces the error: ModuleNotFoundError: No module named 'PyNEC'

My PYTHONPATH includes $HOME/.local/lib/python3.8/site-packages as confirmed by print(sys.path).

The contents of that directory is:

easy-install.pth PyNEC-1.7.3.6-py3.8-linux-x86_64.egg

There is no directory called PyNEC containing an init.py file.

Here are the contents of the one directory:

$ ls PyNEC-1.7.3.6-py3.8-linux-x86_64.egg/ EGG-INFO examples pycache _PyNEC.cpython-38-x86_64-linux-gnu.so _PyNEC.py

jdh4 avatar Feb 23 '21 19:02 jdh4

I have the same issue on MacOS Catalina 10.15.7. Python version is 3.9.1. It used to work last time I tried PyNEC in April 2020.

afiskon avatar Mar 09 '21 21:03 afiskon

As a workaround the previous version can be installed:

pip3 install PyNEC==1.7.3.4

Something was broken between releases 1.7.3.4 (Aug 2019) and 1.7.3.6 (May 2020)

afiskon avatar Mar 09 '21 21:03 afiskon

I have the same issue on MacOS 10.14.6:

$ pip freeze cycler==0.10.0 kiwisolver==1.3.1 matplotlib==3.4.1 necpp==1.7.3.5 numpy==1.20.2 Pillow==8.2.0 PyNEC==1.7.3.6 pyparsing==2.4.7 python-dateutil==2.8.1 scipy==1.6.2 six==1.15.0 $ python -V Python 3.9.4 $

Works after downgrade (but got an error "RuntimeError: SYMMETRY ERROR - NROW: 1929734915 NCOL: 1778416642" - might be my own fault [2021-may-08: Was my fault. PyNEC works in this environment]): $ pip freeze cycler==0.10.0 kiwisolver==1.3.1 matplotlib==3.4.1 necpp==1.7.3.5 numpy==1.20.2 Pillow==8.2.0 PyNEC==1.7.3.4 pyparsing==2.4.7 python-dateutil==2.8.1 scipy==1.6.3 six==1.15.0 $ python -V Python 3.9.4 $

glenndk avatar May 05 '21 19:05 glenndk

@glenndk try requirements.txt from this project https://github.com/afiskon/pynec-examples Worked for me.

afiskon avatar May 07 '21 07:05 afiskon

@afiskon Thanks for your comment. It was a fault in my test program. PyNEC==1.7.3.4 works in this environment:

$ pip freeze cycler==0.10.0 kiwisolver==1.3.1 matplotlib==3.4.1 necpp==1.7.3.5 numpy==1.20.2 Pillow==8.2.0 PyNEC==1.7.3.4 pyparsing==2.4.7 python-dateutil==2.8.1 scipy==1.6.3 six==1.15.0 $ python -V Python 3.9.4 $

glenndk avatar May 08 '21 14:05 glenndk

Similar problem here. "No module named 'PyNEC'". :-(

$ pydoc3 modules

Please wait a moment while I gather a list of all available modules...

_PyNEC  
>>> import _PyNEC
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit__PyNEC)

Benitoite avatar Mar 01 '23 05:03 Benitoite

This is because (on my system at least) the name of the swig binary has changed from swig3.0 to just swig - see build.sh https://github.com/tmolteno/python-necpp/blob/master/PyNEC/build.sh#L17 .

If you look carefully at the output of the build process, swig isn't running at all. Making the above change fixed it for me.

daniel-ayers avatar Mar 15 '23 09:03 daniel-ayers

@daniel-ayers Oh good catch. The module specified installing building with version 3, whereas swig is currently at version 4.

PR https://github.com/tmolteno/python-necpp/pull/26 generated.

Benitoite avatar Mar 15 '23 18:03 Benitoite

I know this is off-topic, but is PyNEC still being actively developed? If so, is there somewhere that provides documentation of the pl_card from the bottom of this page?

aeropung avatar Mar 15 '23 18:03 aeropung

... is there somewhere that provides documentation of the pl_card ...

PyNEC is a Python wrapper around a C++ library that implements a very old (c. 1980) input & output format. To understand the PL card refer to the documentation of the original library - see https://github.com/tmolteno/python-necpp/issues/22#issuecomment-1469618534 .

daniel-ayers avatar Mar 15 '23 20:03 daniel-ayers

As a workaround the previous version can be installed:

pip3 install PyNEC==1.7.3.4

Something was broken between releases 1.7.3.4 (Aug 2019) and 1.7.3.6 (May 2020)

Solved the problem ...

rezamarzban avatar Dec 17 '23 14:12 rezamarzban