Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Syntax error on "python setup.py install" #1125

Closed
rhyolight opened this issue Jul 18, 2014 · 9 comments
Closed

Syntax error on "python setup.py install" #1125

rhyolight opened this issue Jul 18, 2014 · 9 comments

Comments

@rhyolight
Copy link
Member

I always get this error. It doesn't break anything, but it should probably be fixed.

Extracting nupic-0.1.0-py2.7.egg to /usr/local/lib/python2.7/site-packages
  File "/usr/local/lib/python2.7/site-packages/nupic-0.1.0-py2.7.egg/nupic/frameworks/opf/exp_generator/opfExperimentControlTemplate.py", line 4
    "environment": $ENVIRONMENT,
                   ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python2.7/site-packages/nupic-0.1.0-py2.7.egg/nupic/regions/UnimportableNode.py", line 5
    Try to import this, Python interpreter...
         ^
SyntaxError: invalid syntax

This is because the file being parsed is a template, not a python source file. We need to try to exclude templates like this from interpretation somehow.

@david-ragazzi
Copy link
Contributor

  File "/usr/local/lib/python2.7/site-packages/nupic-0.1.0-py2.7.egg/nupic/frameworks/opf/exp_generator/opfExperimentControlTemplate.py", line 4
    "environment": $ENVIRONMENT,
                   ^
SyntaxError: invalid syntax

Is $ENVIRONMENT empty? If yes, syntax error surelly will happen. By the way, shouldn't we use os.getenv['ENVIRONMENT'] for this purpose?

  File "/usr/local/lib/python2.7/site-packages/nupic-0.1.0-py2.7.egg/nupic/regions/UnimportableNode.py", line 5
    Try to import this, Python interpreter...

It thought this error was supposed to happen due to the node be "Unimportable".. See the content of nupic/regions/UnimportableNode.py:

"""This file does NOT contain valid Python code. It is used to test
error handling when trying to import "bad" Python nodes
"""

Try to import this, Python interpreter...

Maybe we should turn OFF the verbosity for this file.

@ChrisRJernigan
Copy link

I had this problem too when I was using Python 2.7.7 and IPython. Every time I tried to import nupic I would get a fatal error. That's when I decided to back-up and wipe my startup disk and completely reinstall Mavericks. It's a pretty brute force approach but it worked. The problem might have something to do with the Python version since the default version on Mavericks is 2.7.5

@rhyolight
Copy link
Member Author

@david-ragazzi The problem is that opfExperimentControlTemplate.py is not a python file. It is not interpretable at all. The $ENVIRONMENT is supposed to be replaced at runtime with some injected variable and turned into a dynamically created source file. We just need an option to ignore this file or perhaps rename it to opfExperimentControlTemplate.py.tmpl?

@rhyolight
Copy link
Member Author

In fact, all the files in the exp_generator directory have .tpl extensions except for this one file. I think we just need to update the extension and the code the uses it.

I will test it out and see if I can do a simple fix.

@rhyolight rhyolight added this to the Sprint 26 milestone Jul 18, 2014
@rhyolight rhyolight self-assigned this Jul 18, 2014
@rhyolight
Copy link
Member Author

The offending files doesn't look like it's being used anymore. I'm going to create a PR with the file removed and watch the build.

@rhyolight
Copy link
Member Author

There is also one other file causing a syntax error:

  File "/usr/local/lib/python2.7/site-packages/nupic-0.1.0-py2.7.egg/nupic/regions/UnimportableNode.py", line 5
    Try to import this, Python interpreter...
         ^
SyntaxError: invalid syntax

This is used for tests, but should not be included in the build.

@rhyolight
Copy link
Member Author

@david-ragazzi Do you know how I can exclude a python source file from being interpreted during the build?

@david-ragazzi
Copy link
Contributor

@david-ragazzi Do you know how I can exclude a python source file from being interpreted during the build?

I've no idea, because as far I know SetupTools is compiling each file to be imported. Why we simply don't exclude it?

@rhyolight
Copy link
Member Author

@david-ragazzi This file is used in unit tests at tests/unit/py2/nupic/engine/network_test.py. So we can't exclude it entirely.

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

No branches or pull requests

3 participants