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 ?
Related
I'm using Spyder, vermin is installed. In the Spyder console, I type:
vermin test_script.py
and the output is:
File "C:\Users\me\AppData\Local\Temp/ipykernel_20048/1234567890.py", line 1
vermin test_script.py
^
SyntaxError: invalid syntax
How should I fix what I'm doing? I get the same error whether I use absolute or relative path, or put the path in quotes.
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!
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.
I have been using py2neo on my local machine and it's been working great. However, when I installed it out on my server I received an error before it said Successfully Installed.
This was the error:
File "/usr/lib/python2.5/site-packages/py2neo/cypher.py", line 112
except rest.BadRequest as err:
^
SyntaxError: invalid syntax
File "/usr/lib/python2.5/site-packages/py2neo/rest.py", line 345
except httplib.HTTPException as err:
^
SyntaxError: invalid syntax
Sure enough when I try and use py2neo out on my server I get an error:
invalid syntax (rest.py, line 345)
Locally I'm running python 2.7.2 where as on the server I'm running 2.5.2 Is this a known issue with the python versions?
As mentioned on the website, py2neo is only compatible with Python 2.6 and upwards. Sorry!
This question already has answers here:
Invalid syntax (SyntaxError) in except handler when using comma
(5 answers)
What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?
(11 answers)
Closed last month.
I am trying to install python on windows, and this is my first day on python. Install goes well on windows 7 x64. But almost all scripts fails. I am trying to install celery and running following command on celery folder.
python setup.py build
and it fails, following is an error
File "setup.py", line 40
except ImportError, exc:
^
SyntaxError: invalid syntax
also following fails, which is valid print command i think.
>>> print 'a'
File "<stdin>", line 1
print 'a'
^
SyntaxError: invalid syntax
I am sure i am missing something here. Any idea what makes it fail?
Edit:
Below is summary of tasks i had to go through to get python working, made notes for myself but putting it here as well if it can help anyone
Install python and celery
=========================
-celery does not work with python3, so install latest python2
-install windows install for python2
-add C:\python2X to %PATH%
-set python path for lib
set PYTHONPATH=%PYTHONPATH%;c:\python2x
-install setuptools
http://pypi.python.org/pypi/setuptools
for x64 install does not work use
python setup.py install
-then can use easy_install
-now just use easy_install to install everything
A likely cause is version incompatibility, as Vincent Savard pointed out. Python 3 is not backwards compatible with Python 2
if print 1 doesn't work, but print(1) does, then you are running python 3, which seems to be the case
for Python 3 the syntax has been changed so
Change from except exc, var to except exc as var.
viz ( http://docs.python.org/release/3.1.3/whatsnew/3.0.html )
except ImportError, exc:
should be
except ImportError as exc:
Yeah you're probably running python 3. Try print("hello world")
If that works then you're running python 3