Invalid syntax in "hclass3.py to hclass3.pyc"

Post Reply
bremen
Posts: 45
Joined: Mon Apr 24, 2017 8:15 am
Location: Italy

Invalid syntax in "hclass3.py to hclass3.pyc"

Post by bremen »

Hi.

I'm doing new installations of the latest NEURON code, from the git repository, and there is a SyntaxError which i haven't seen in previous builds.
It does compile till the end and everything seems running as usual.

Code: Select all

byte-compiling /nrn/lib/python/neuron/hclass3.py to hclass3.pyc
  File "/nrn/lib/python/neuron/hclass3.py", line 30
    class hc(hoc.HocObject, metaclass=MetaHocObject):
                                     ^
SyntaxError: invalid syntax
Ubuntu 16.04.3 64bit and CentOS 7 64bit.

Best regards
Stefano Masoli
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Invalid syntax in "hclass3.py to hclass3.pyc"

Post by hines »

A similar issue was posted to
https://github.com/nrnhines/nrn/issues/60
I'm getting the following error on Mac OS X High Sierra (Python 2.7.14 provided by pyenv), when compiling Neuron:

byte-compiling /Users/werner/local/nrnnogui/lib/python2.7/site-packages/neuron/hclass3.py to hclass3.pyc
File "/Users/werner/local/nrnnogui/lib/python2.7/site-packages/neuron/hclass3.py", line 30
class hc(hoc.HocObject, metaclass=MetaHocObject):
^
SyntaxError: invalid syntax

It seems it's not a fatal error, because the build process finishes 'normally'

configure options: ../configure --with-nrnpython --without-x --disable-rx3d
My response was:
Thanks. That is ok because hclass3.py is not imported by neuron/init.py if the python major
version is not 3. (hclass2.py and hclass3.py exist soley because of the different syntax required by
python major versons 2 and 3.). If anyone knows how to avoid in your situation trying to compile if not imported, I'd like to know as that
could avoid the error. I wonder if the contents of hclass2.py and hclass3.py could become a string
that is executed based on the value of sys.version_info[0].
Did you experience this on Mac OS X High Sierra (Python 2.7.14) ? Or should we expect this problem to occur more generally unless it is explicitly
fixed?
Post Reply