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

Just Cause does not install on Python 3.6.9 #21

Closed
Tanmay-Kulkarni101 opened this issue Feb 7, 2020 · 6 comments
Closed

Just Cause does not install on Python 3.6.9 #21

Tanmay-Kulkarni101 opened this issue Feb 7, 2020 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Tanmay-Kulkarni101
Copy link
Contributor

Tanmay-Kulkarni101 commented Feb 7, 2020

I tried installing just cause on Python 3.6.9. I have already installed R and it seemed to have installed correctly with pip3. However, on execution, I got the following log:

python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import justcause
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tanmay/model_env/lib/python3.6/site-packages/justcause/__init__.py", line 4, in <module>
    from . import data
  File "/home/tanmay/model_env/lib/python3.6/site-packages/justcause/data/__init__.py", line 14, in <module>
    from . import sets
  File "/home/tanmay/model_env/lib/python3.6/site-packages/justcause/data/sets/__init__.py", line 24, in <module>
    from .ibm import load_ibm
  File "/home/tanmay/model_env/lib/python3.6/site-packages/justcause/data/sets/ibm.py", line 23, in <module>
    from ..frames import CausalFrame, Col
  File "/home/tanmay/model_env/lib/python3.6/site-packages/justcause/data/frames.py", line 4
    from __future__ import annotations
    ^
SyntaxError: future feature annotations is not defined

Can anyone help me out?

@FlorianWilhelm
Copy link
Collaborator

Hi @Tanmay-Kulkarni101, thanks for reporting. This is a bug on our side. It seems like this import was only introduced in Python 3.7. Could you try on Python 3.7?

@MaximilianFranz, could you make the import only if Python is greater or equal than 3.7?

@MaximilianFranz
Copy link
Contributor

This is indeed because of the annotations feature only being available in __future__ from Python 3.7 (PEP563).
I can add a conditional import, though __future__ imports ought to remain at the beginning of the file, which is not the case, if I first import sys for checking the version

import sys
if sys.version_info >= (3, 7):
    from __future__ import annotations

@MaximilianFranz
Copy link
Contributor

MaximilianFranz commented Feb 7, 2020

Adding a __future__ import anywhere but at the start of the file leads to a SyntaxError:

Python 3.7.6 | packaged by conda-forge | (default, Dec 26 2019, 23:46:52)
[Clang 9.0.0 (tags/RELEASE_900/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> if sys.version_info >= (3,7):
...     from __future__ import annotations
...
  File "<stdin>", line 2
SyntaxError: from __future__ imports must occur at the beginning of the file

Thus, we can either require Python 3.7 for JustCause or remove the import, as far as I can see.

Here they have the same issue and resolve it by removing the future import. Then, all annotations (also type-hints) referring to the self class apparently need to be put into strings instead.

Thanks for reporting, this seems to be a real issue.

@MaximilianFranz MaximilianFranz added the bug Something isn't working label Feb 7, 2020
@MaximilianFranz MaximilianFranz self-assigned this Feb 7, 2020
@Tanmay-Kulkarni101
Copy link
Contributor Author

I will try to run it with Python3,7 in that case. Thanks for your help.

MaximilianFranz added a commit that referenced this issue Feb 15, 2020
For now, we comment out the use of annotations from the __future__
module and use the "old" way with string notation for type annotations
refering to the 'self' class.
@FlorianWilhelm FlorianWilhelm added this to the v0.3.1 milestone Feb 15, 2020
MaximilianFranz added a commit that referenced this issue Feb 18, 2020
For now, we comment out the use of annotations from the __future__
module and use the "old" way with string notation for type annotations
refering to the 'self' class.
@FlorianWilhelm
Copy link
Collaborator

This still isn't fixed and is also a bug in the version 0.3.1 release for Python 3.6 since from __future__ import annotations is still for instance in the transport.py module.

@FlorianWilhelm
Copy link
Collaborator

Thanks @MaximilianFranz, just tested it and importing justcause works under Python 2.6.10. I pushed to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants