syntax error in every python scripts SyntaxError: invalid syntax - python

File "account_creator.py", line 63
username = f"{first_name}_{last_name}{random.randint(1000, 9999)}"
^
SyntaxError: invalid syntax
every script i run gives this error

You need to use a newer version of Python. Install a version of python 3.6 or newer, then your problem should be solved!

Related

Pyinstaller - invalid syntax

I am trying to use pyinstaller to package my script into an exe.
All sources indicate that the correct syntax is: pyinstaller FullClientCreator.py
When I issue this command, I get a syntax error:
pyinstaller FullClientCreator.py
File "C:\Users\DAVIDM~1\AppData\Local\Temp/ipykernel_7368/3509825318.py", line 1
pyinstaller FullClientCreator.py
^
SyntaxError: invalid syntax
I also tried it with the full path for the file, and I still get the same error:
pyinstaller "D:\Projects\ZZNew Client CreatorZZ\FullClientCreator.py"
File "C:\Users\DAVIDM~1\AppData\Local\Temp/ipykernel_7368/546891165.py", line 1
pyinstaller "D:\Projects\ZZNew Client CreatorZZ\FullClientCreator.py"
^
SyntaxError: invalid syntax
I am at a complete loss as to why this could be, so if anyone has any suggestions, I would greatly appreciate them.
Try another shell
I dont know which shell are you using but if you're using python shell sometimes its not working for python shell so try it on your cmd
pyinstaller --onefile file.py

zeppelin_ipyspark.py at apache zeppelin get SyntaxError: invalid syntax

when i running code with pyspark in apache zeppelin 0.8.1 , i get error like
java.lang.NullPointerException
at org.apache.thrift.transport.TSocket.open(TSocket.java:170)
at org.apache.zeppelin.interpreter.remote.ClientFactory.create(ClientFactory.java:51)
...
so i open all file in my folder zeppelin
and i try to running file zeppelin_ipyspark.py at D:\zeppelin-0.8.1-bin-all\interpreter\spark\python with cmd
and i get error
D:\zeppelin-0.8.1-bin-all\interpreter\spark\python>zeppelin_ipyspark.py
File "D:\zeppelin-0.8.1-bin-all\interpreter\spark\python\zeppelin_ipyspark.py", line 29
port=${JVM_GATEWAY_PORT}, auth_token=gateway_secret, auto_convert=True))
^
SyntaxError: invalid syntax
so can you help me?
#LSS zeppelin_ipyspark.py is not a standalone script.
It is invoked internally from Zeppelin's java code as part of Ipython interpreter, where the python script is processed to replace these strings(like JVM_GATEWAY_PORT etc) with actual values.
You can check the code references: 1, 2

Error in django-app-metrics

I am using django-app-metrics for recording some metrics in my webapp. I using python3 and i installed app-metrics using following command - pip3 install django-app-metrics.
But when I am importing from app_metrics.utils import create_metric it is giving me this error :
File "/usr/local/lib/python3.6/site-packages/app_metrics/utils.py", line 92
except Exception, e
^
SyntaxError: invalid syntax
Can someone tell me what i am doing wrong ?

emacs python jedi error

I am trying to setup my GNU Emacs 24.3.1 for python development following the instructions here:
https://www.youtube.com/watch?v=0cZ7szFuz18
The installation gave a few warnings but was successful. Then I open a new buffer with file 01.py and try to use the auto-complete:
import os
os.
But get this error:
deferred error : (error Server may raise an error : File "/home/avilella/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py", line 71
return _WHITESPACES_RE.sub(' ', desc) if desc and desc != 'None' else ''
^
SyntaxError: invalid syntax
)
Any ideas what is going on?
emacs is using an old version of python. The code that gets the error is python 2.6+ syntax I believe.

install error or error running python file

I am running a basic Python file on Windows XP from IDLE.
The file name is assignment1.py.
The file content is:
import sys
var = 5
but when I run it, it gives the error:
Command: python assignment1.py
SyntaxError: invalid syntax
Then I tried another thing which also gave an error:
Command: which python
SyntaxError: invalid syntax
Not sure if the installation is wrong or something.
I am able to run the print command successfully:
>>> print "I am working fine"
I am working fine
Not sure of the issue. Request help.
It looks like what you are entering as the "command" is being interpreted as Python code. I mean, python assignment1.py is interpreted as Python code. The result is as expected:
$ python -c 'python assignment1.py'
File "<string>", line 1
python assignment1.py
^
SyntaxError: invalid syntax
You need to run the file in the correct way, probably via the IDLE menu or by pressing F5. You can check these questions for details:
How do I run a Python program?
Running Python script from IDLE on Windows 7 64 bit

Categories

Resources