0

After changing some environmental variable for PYTHONHOME and updating pycharm and python my console kept spitting out this error:

def __new__(mcls, name, bases, namespace, /, **kwargs)
                                          ^ 
SyntaxError: invalid syntax

I've search through some similar problems and tried to reinstall python and let it set the path but the problem still occurred. For reference my first error that lead to this was akin to what happened int his question: Fatal Python error on Windows 10 ModuleNotFoundError: No module named 'encodings'.

Then i tried the solution in this question: Fatal Python error: init_sys_streams: can't initialize sys standard streams AttributeError: module 'io' has no attribute 'OpenWrapper'

And now i found myself with the above error of which am at a standstill. Ive tried looking for the syntax one would use for this new and perhaps found the error in there but so far no good.

Edit 1: Removed a / from _py_abc.py and it now says ImportError: cannot import name 'open_code'

Lohmar ASHAR
  • 1,639
  • 14
  • 18
  • what is the current value of your PYTHONHOME? Try opening a session in a terminal, then $: export PYTHONHOME='' And then launch python in that same terminal, see what happend – E.Serra Dec 16 '19 at 17:18
  • The current value is C:\Users\Wally\AppData\Local\Programs\Python\Python38-32\ and i must admit am still very new to python and i am struggling to do your request. – Ross Geomans Jr. Dec 16 '19 at 17:26
  • Could You post the code, that produces the error here? Syntax Errors don't just appear, maybe the PYTHONHOME is a red herring. Or the expression ``new`` was added to python and you switched versions. – AlexNe Dec 16 '19 at 19:12
  • You could also try to run your code here: https://repl.it/languages/python3 and see if it works. – AlexNe Dec 16 '19 at 19:15
  • The error happens with any code I've written before, any new code I write and no code at all. I believe its pycharm as I can run a program I had converted to an exe with pyinstaller. – Ross Geomans Jr. Dec 16 '19 at 19:31

1 Answers1

0

I've got the same error after I've installed and tried to use python 3.8 in eclipse.
The exact line of code is inside the _py_abc.py module/file, and it contains a feature that was introduced in python3.8, the positional only parameters.

In my case, the error was raised while pylint (which was installed with pip2/python2) was trying to ... lint, and persisted even after I've installed pylint with pip3/python3 (which in my Ubuntu 18.04 WSL points to python3.6). I've managed to overcome the problem only after I've installed pylint explicitly with python3.8.

So, this whole ranting about pylint is only to explain how I got the error and how I understood the problem which basically is: some thing inside the IDE is trying to use some pre-3.8 executable to run something that should be run with a python3.8+ executable.

Lohmar ASHAR
  • 1,639
  • 14
  • 18