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

SyntaxError on macOS #146

Open
neosalmon opened this issue Jun 30, 2018 · 9 comments
Open

SyntaxError on macOS #146

neosalmon opened this issue Jun 30, 2018 · 9 comments

Comments

@neosalmon
Copy link

I encountered

 username@rootbox: pokemon _pikachu
Traceback (most recent call last):
  File "/usr/local/bin/pokemon", line 5, in <module>
    from pokemonterminal.main import main
  File "/Library/Python/2.7/site-packages/pokemonterminal/main.py", line 37
    print(f"Starting slideshow with {len(filtered)}, pokemon " +
                                                             ^
SyntaxError: invalid syntax

and:

username@rootbox: pokemon
Traceback (most recent call last):
  File "/usr/local/bin/pokemon", line 5, in <module>
    from pokemonterminal.main import main
  File "/Library/Python/2.7/site-packages/pokemonterminal/main.py", line 37
    print(f"Starting slideshow with {len(filtered)}, pokemon " +
                                                             ^
SyntaxError: invalid syntax

after a successful installation on macOS

@sylveon
Copy link
Collaborator

sylveon commented Jun 30, 2018

You need at least Python 3.6, your stack indicates you are using Python 2.7.

@neosalmon
Copy link
Author

That's strange, I do have python 3.7.0 installed via Homebrew

@sylveon
Copy link
Collaborator

sylveon commented Jun 30, 2018

Your method of installation seems to have installed it for Python 2.7. How did you install it?

@neosalmon
Copy link
Author

Initially, I was using the pre-installed version of Python, after which I ran brew install python to fetch the latest version.

@samuelhnrq
Copy link
Collaborator

Just so I can keep in here for future reference:

Python got a lot of development in version 2 way too fast without much planning, which made a mess, which would involve making backwards incompatible changes in order to fix, but making such move so soon in the language would be too big of a shot in the foot, so they decided to maintain both versions, the 2 for legacy compatibility, and for butthurts who doesn't like change (it is open source after all people can keep python 2 alive forever), and 3 for all future development.

A lot of operating of operational systems, specially the more conservative ones which consider anything less then 3 years old is way too volatile, refused to (rewrite a lot of code) adapt to the new version. Which virtually makes python 2 the default, which is incompatible with our code that uses a lot of 3.6 features. e.g. fstrings:

Traceback (most recent call last):
  File "/usr/local/bin/pokemon", line 5, in <module>
    from pokemonterminal.main import main
  File "/Library/Python/2.7/site-packages/pokemonterminal/main.py", line 37
    print(f"Starting slideshow with {len(filtered)}, pokemon " +
                                                             ^
SyntaxError: invalid syntax

@sylveon
Copy link
Collaborator

sylveon commented Jul 11, 2018

My guess is that you used pip to install the pokemon-terminal package. The pip command on your system must default to the package installer for Python 2. You can explicitly use a more recent pip by adding a version number to the command, like so:

pip3 --help
# or
pip3.6 --help

I'm not that used to pip packaging, but it would be great to fail install (or warn) if we aren't installing to Python >= 3.6

@giftig
Copy link

giftig commented Jul 11, 2018

That's easy enough to do; you can put a check in your setup. Actually there's a package you can use as a dependency which literally just does this check for you: https://pypi.org/project/require-python-3/ though it seems a bit overkill for something you could write yourself in 2 lines.

Looks like there's an official way to do this now: https://packaging.python.org/guides/dropping-older-python-versions/

@sylveon
Copy link
Collaborator

sylveon commented Jul 11, 2018

That python_requires is already there in the setup.py

Since his python didn't catch it up (probably too outdated to support that key), we should add a few lines of manual check.

import sys
assert (sys.version_info.major >= 3 and sys.version_info.minor >= 6), "Pokémon-Terminal requires at least Python 3.6"

@giftig
Copy link

giftig commented Jul 11, 2018

It's supported by pip9+, current version is 10.0.1. It seems like an odd choice to me to deliberately drop support for python2.7 but attempt to support versions of pip two major versions out of date, but to each their own.

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

No branches or pull requests

4 participants