compas-dev / compas

Core packages of the COMPAS framework.
https://compas.dev/compas/
MIT License
308 stars 104 forks source link

`Runtime error (SyntaxErrorException): unexpected token 'from'` when importing `compas` #1184

Closed chenkasirer closed 11 months ago

chenkasirer commented 11 months ago

Describe the bug On some computers, when attempting to import compas inside GHPython, getting the following error:

Runtime error (SyntaxErrorException): unexpected token 'from'

Traceback:
  line 25, in <module>, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\data\encoders.py"
  line 11, in <module>, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\data\__init__.py"
  line 19, in <module>, "C:\Users\ckasirer\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\__init__.py"
  line 5, in script

This would typically happen when installing COMPAS to Rhino for the first time.

To Reproduce Steps to reproduce the behavior:

  1. Install COMPAS
  2. Install COMPAS to Rhino python -m compas_rhino.install
  3. Open a new GHPython component
  4. import compas

Expected behavior compas should be imported successfully.

Desktop (please complete the following information):

Additional context This has been spotted to happen where numpy is available in sys.path inside GH. This can be the case when, but not necessarily always, Ladybug is installed (since it downloads a python3 interpreter and adds its site-packges to sys.path).

Farzanbnh commented 11 months ago

Hi chekasirer, I am getting the same error on a Microsoft Windows 11 Pro for Workstations

Runtime error (SyntaxErrorException): unexpected token 'from'

Traceback: line 26, in , "C:\Users\offic\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\data\encoders.py" line 13, in , "C:\Users\offic\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\data\validators.py" line 68, in , "C:\Users\offic\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas\data__init.py" line 45, in , "C:\Users\offic\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas__init__.py" line 20, in , "C:\Users\offic\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas_ghpython\init__.py" line 1, in script

gonzalocasas commented 11 months ago

@Farzanbnh We release a new compas LTS version very very soon containing a fix for this. In the meantime, you could uninstall ladybug if you need a quick solution.

gonzalocasas commented 11 months ago

@Farzanbnh we just released compas 1.17.7, it's already on pip, conda will still take some more hours but you could already try to update your environment with the pip release and that should solve the problem