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

Issue with binary installer on OS X : ModuleNotFoundError: No module named 'neuron.hoc38' #611

Closed
pramodk opened this issue Jun 24, 2020 · 15 comments

Comments

@pramodk
Copy link
Member

pramodk commented Jun 24, 2020

One of our internal user had issue on OSX so I tried to install NEURON via OSX installer. I am seeing following:

  • 3.5 & 3.8 have below issue:
→ python3.5 test1.py
Traceback (most recent call last):
  File "/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py", line 106, in <module>
    import hoc
ImportError: No module named 'hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py", line 110, in <module>
    import neuron.hoc
ImportError: dlopen(/Applications/NEURON-7.7/nrn/lib/python/neuron/hoc.so, 2): Symbol not found: __Py_ZeroStruct
  Referenced from: /Applications/NEURON-7.7/nrn/x86_64/lib/libnrnpython2.0.dylib
  Expected in: flat namespace
 in /Applications/NEURON-7.7/nrn/x86_64/lib/libnrnpython2.0.dylib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test1.py", line 1, in <module>
    import neuron, os
  File "/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py", line 112, in <module>
    exec("import neuron.hoc%d%d as hoc" % (sys.version_info[0], sys.version_info[1]))
  File "<string>", line 1, in <module>
ImportError: No module named 'neuron.hoc35'

○ → python3.8 test1.py
/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py:430: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if len(nt_dlls) is 0:
/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py:432: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if h.nrnversion(8).find('i686') is 0:
Traceback (most recent call last):
  File "/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py", line 106, in <module>
    import hoc
ModuleNotFoundError: No module named 'hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py", line 110, in <module>
    import neuron.hoc
ImportError: dlopen(/Applications/NEURON-7.7/nrn/lib/python/neuron/hoc.so, 2): Symbol not found: __Py_ZeroStruct
  Referenced from: /Applications/NEURON-7.7/nrn/x86_64/lib/libnrnpython2.0.dylib
  Expected in: flat namespace
 in /Applications/NEURON-7.7/nrn/x86_64/lib/libnrnpython2.0.dylib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test1.py", line 1, in <module>
    import neuron, os
  File "/Applications/NEURON-7.7/nrn/lib/python/neuron/__init__.py", line 112, in <module>
    exec("import neuron.hoc%d%d as hoc" % (sys.version_info[0], sys.version_info[1]))
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'neuron.hoc38'
  • 3.6 & 3.7 is working fine
 → python3.6 test1.py
 → python3.7 test1.py
@nrnhines
Copy link
Member

dlopen(/Applications/NEURON-7.7/nrn/lib/python/neuron...
That does not seem very recent. What installer are we talking about? Maybe the problem is a left over PYTHONPATH

@pramodk
Copy link
Member Author

pramodk commented Jun 24, 2020

This is default 7.7 available from the website : https://www.neuron.yale.edu/neuron/download

Maybe the problem is a left over PYTHONPATH

Do you meant if I have another neuron installation mentioned in PYTHONPATH?

@nrnhines
Copy link
Member

That version is link to https://neuron.yale.edu/ftp/neuron/versions/v7.7/7.7.2/nrn-7.7.2.x86_64-osx-py-37-36-27.pkg
which cannot be used with 3.5 or 3.8

@pramodk
Copy link
Member Author

pramodk commented Jun 24, 2020

Ah interesting ! But the download page doesn’t mention anything about this? I think regular users will miss this (as happened to me as well).

@nrnhines
Copy link
Member

nrnhines commented Jun 24, 2020

I agree. An appropriate error message is needed if the neuron module has no hoc module compatible with the launched python.
Also, the current strategy in neuron/init.py to import hoc by trying a sequence of try: import hoc... needs to be redone.
It is ironic that it is likely (or perhaps I should say, possible) any of the hoc...3.x...dylib would in fact work for any python3.y. It is just that the python3.y's import hoc is looking for a specific filename that contains the 3.y tokens.

It would be possible to work around this issue by using the abi3 version of hoc...dylib. The problem is that I haven't yet been able to make the corresponding dylib modules for rx3d.

@pramodk
Copy link
Member Author

pramodk commented Jun 26, 2020

@nrnhines : we should also consider integrating OS X installer creation on Azure. As we started for Windows in #572 .

@Siefeldin-sobih-zz
Copy link

I am having quite the similar problem, could someone please just direct me on what to do ?
So I have tried import neuron in pycharm, I get the following error (Even when I install the package folder from pycharm source list), I am using 3.8+ ver of python and latest pycharm version.
Traceback (most recent call last): File "c:\nrn\lib\python\neuron__init__.py", line 106, in import hoc ModuleNotFoundError: No module named 'hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\nrn\lib\python\neuron__init__.py", line 110, in import neuron.hoc ModuleNotFoundError: No module named 'neuron.hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:/pythonProject/main.py", line 1, in import neuron File "c:\nrn\lib\python\neuron__init__.py", line 112, in exec("import neuron.hoc%d%d as hoc" % (sys.version_info[0], sys.version_info[1])) File "", line 1, in ModuleNotFoundError: No module named 'neuron.hoc38'

Process finished with exit code 1

When I try with Anaconda prompt, I get this
Traceback (most recent call last):
File "c:\nrn\lib\python\neuron_init_.py", line 106, in
import hoc
ModuleNotFoundError: No module named 'hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\nrn\lib\python\neuron_init_.py", line 110, in
import neuron.hoc
ModuleNotFoundError: No module named 'neuron.hoc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "c:\nrn\lib\python\neuron_init_.py", line 112, in
exec("import neuron.hoc%d%d as hoc" % (sys.version_info[0], sys.version_info[1]))
File "", line 1, in
ModuleNotFoundError: No module named 'neuron.hoc38'

I just need to get it working on either of those two (Pycharm prefered) What should I do ?

@pramodk
Copy link
Member Author

pramodk commented Aug 8, 2020

@saifaldin : could you try our pip package? i.e. try

pip3 install neuron

(replace pip3 with the version of pip corresponding to your Python)

@Siefeldin-sobih-zz
Copy link

I am using Windows 64 bit, isn't pip command for Linux shell ?

@ramcdougal
Copy link
Member

The Windows NEURON 7.7 installer does not support Python 3.8 because 7.7 came out before Python 3.8.

If you want to run NEURON with Python 3.8 on Windows, use the 7.8 semi-official release at https://neuron.yale.edu/ftp/neuron/versions/alpha/nrn-7.8.1.w64-mingw-py-27-35-36-37-38-setup.exe

(You are sort-of correct; pip for NEURON only gives you a recent version for Linux and macOS at this time.)

@Siefeldin-sobih-zz
Copy link

Siefeldin-sobih-zz commented Aug 8, 2020

use the 7.8 sem

Oh okay, sounds like a good start. Please could you just walk me through it just a little bit ?
So what I will do now is uninstall the previous Neuron package that I have installed. Then restart/clean reg and install the one you have just posted here.

What should I do afterwards from Pycharm or Anaconda ?! Or should I just type " import neuron" again and they will recognize it ?

@ramcdougal
Copy link
Member

That's probably the best: uninstall, then install. Then everything should just work.

It looks like Anaconda and pycharm are successfully connecting to the library as a whole... the key part of the error message is when it says that it's failing on finding neuron.hoc38... the 38 there corresponds to a version of NEURON that supports Python 3.8 (which is true because there is no such thing for 7.7).

@Siefeldin-sobih-zz
Copy link

Siefeldin-sobih-zz commented Aug 8, 2020

That's probably the best: uninstall, then install. Then everything should just work.

It looks like Anaconda and pycharm are successfully connecting to the library as a whole... the key part of the error message is when it says that it's failing on finding neuron.hoc38... the 38 there corresponds to a version of NEURON that supports Python 3.8 (which is true because there is no such thing for 7.7).

OH MY GOD ! IT WORKED !
Thank you so much Ram, I have been trying to get this working for 2 days now because I am not yet familiar with coding and all of that.
It is for my course by the Blue brain project, they require it alot Thankssss !!!!

What I did basically is the simple uninstall/reinstall, then just reopened pycharm and allowed it to verify the import function all over again ! Thank you.

@nrnhines
Copy link
Member

nrnhines commented Aug 8, 2020

The error message involving neuron,hoc38 needs a bit of improved clarity. That's a legacy last fallback try that is relevant only for my non-standard naming convention used for an autotools build that did not make use of setup.py.
The new cmake build does make use of setup.py and the standard python naming convention for shared library modules.
In your case, hoc.cp38-win-amd64.pyd

@Siefeldin-sobih-zz
Copy link

naming convention used for

Umm.. Thanks for your reply, it is appreciated. I do not really understand what you are trying to imply due to my weak knowledge in this area in general. However it was solved above by the help of Ram, thank you !

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

No branches or pull requests

5 participants