Warning: 'as' will become a reserved keyword in Python 2.6 - python

while running npm install (e.g. https://github.com/donpark/html2jade), I run into this error:
/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py:852: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp", line 15, in <module>
import gyp
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
import gyp.input
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 852
except ImportError as e:
^
SyntaxError: invalid syntax
python --version generates 'Python 2.7.1'

This would not be a syntax error in Python 2.7.1. A quick workaround would be to run this programme as python /full/path/to/scriptname.py, which will actually use Python 2.7.1.

Related

Error running the pyAudioAnalysis sample program

I installed pyAudioAnalysis on python2.7 using pycharm (linux). Trying to run audioBasicIO.py gives the following error. I have installed eyeD3 but it does not work.
/usr/bin/python2.7 /usr/local/lib/python2.7/dist-packages/pyAudioAnalysis/audioBasicIO.py
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pyAudioAnalysis/audioBasicIO.py", line 6, in <module>
import eyed3
File "/home/.local/lib/python2.7/site-packages/eyed3/__init__.py", line 31, in <module>
from .utils.log import log # noqa: E402
File "/home/.local/lib/python2.7/site-packages/eyed3/utils/__init__.py", line 361
msg = f"invalid level choice: {level} (choose from {parser.log_levels})"
^
SyntaxError: invalid syntax
Is my installation incorrect? This is the first time I use this library, does anyone have any suggestions.
f-strings aren't supported for python 2.7. You need python 3.6 or above to use them. Here is a good workaround, in which you can use f-strings in below python 3.6.

How to change python command to use python2 again

I'm running a script and I get a comma error:
dbconfigure -a abc -d ...
Traceback (most recent call last):
File "/usr/local/bin/dbconf", line 6, in <module>
from dbconf import main
File "/usr/local/lib/python3.7/site-packages/dbconf/__init__.py", line 308
except SDBResponseError, exc:
^
SyntaxError: invalid syntax
So I think the script uses a python command but the python command on my computer points to a python3 version. How do I fix this?
You can put the shebang header on Unix (including mac os). First line of your script should be #! /usr/bin/env python2

Trouble installing pyGObject on python3

I keep getting error messages while trying to install PyGObject on python3 (Mac OS X 10.9)
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/var/folders/zh/hww3rvgx1rg62zwc8ct51r1r0000gn/T/pip-build-v5qjvi2y/pygobject/setup.py", line 272
raise SystemExit, 'ERROR: Nothing to do, gio could not be found and is essential.'
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/zh/hww3rvgx1rg62zwc8ct51r1r0000gn/T/pip-build-v5qjvi2y/pygobject
You are trying to install a python2 module with python 3. The syntax error occurs because there has been a change to the syntax for raising an exception. raise SystemExit, 'Message' has become raise SystemExit('Message')
You should make sure that you have the python3 versions of the module.

Using ImageScanner Module with Python 3.4 on Windows

I have installed imagescanner module on windows following this steps . I have connected to scanner on wifi . When I try this code :
from imagescanner import ImageScanner
iscanner = ImageScanner()
scanners = iscanner.list_scanners()
print(scanners[0])
an error message occured :
C:\Python3.4\python.exe C:/Users/PB/PycharmProjects/ImageScanner/deneme.py
Traceback (most recent call last):
File "C:/Users/PB/PycharmProjects/ImageScanner/deneme.py", line 4, in <module>
from imagescanner import ImageScanner
File "C:\Python3.4\lib\site-packages\imagescanner-0.9-py3.4.egg\imagescanner\__init__.py", line 2, in <module>
from imagescanner.core._imagescanner import ImageScanner
File "C:\Python3.4\lib\site-packages\imagescanner-0.9-py3.4.egg\imagescanner\core\_imagescanner.py", line 61
except Exception, exc:
^
SyntaxError: invalid syntax
Process finished with exit code 1
As far as I know, imagescanner isn't compatible with Python 3.
You can try to fix it. The SyntaxError refers to the old syntax for exceptions ("class, variable" become "class as variable" in newer versions). But I'm not sure what other problems you can find.

Error installing selenium python

Getting this error when running pip install -U selenium. Mid way through the script, it gets the following SyntaxError:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Python32\Scripts\build\rdflib\setup.py", line 6, in <module>
from rdflib import __version__
File "rdflib\__init__.py", line 64, in <module>
from rdflib.term import URIRef, BNode, Literal, Variable
File "rdflib\term.py", line 367
except TypeError, te:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Python32\Scripts\build\rdflib\setup.py", line 6, in <module>
from rdflib import __version__
File "rdflib\__init__.py", line 64, in <module>
from rdflib.term import URIRef, BNode, Literal, Variable
File "rdflib\term.py", line 367
except TypeError, te:
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Since it is a Syntax Error, I assume it is a python version problem, I'm running 3.2.2.
Pip did come with a pip-3.2.exe file, which I tried to run. But I got the same error. I'm pretty new to Python so it might be something simple.
And how can it be a syntaxError? pip is an already made program.
Running Win7, Python 3.2.2
Selenium does not support Python 3. Use Python 2.7 instead.
Sadly, almost all Python software requires Python 2.x.
[Update]
Selenium supports Python 3.x now.

Categories

Resources