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.
Related
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!
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
This question already has answers here:
Invalid syntax (SyntaxError) in except handler when using comma
(5 answers)
Closed last month.
I have installed Python 3.6 or 3.7 with Cassandra 3.11.3.
But it does not supporte cqlsh, it only supports the Python 2.7 version.
This is the error message:
\apache-cassandra-3.11.3\bin\\cqlsh.py", line 146
except ImportError, e:
^
SyntaxError: invalid syntax
What may be the problem?
Change
except a, b:
to
except a as b:
Add parens to prints
Change:
except ImportError, e:
To:
except ImportError as ex:
or
except ImportError:
Cqlsh is written in Py2.7, so it'll not build on py3 wrapper env. Even if you change the exception line, it'll not compile the. For example, take this line:
File "/home/usr/.local/bin/cqlsh", line 212
print '\nWarning: Specified cqlshrc location `%s` does not exist. Using `%s` instead.\n' % (CONFIG_FILE, HISTORY_DIR)
^
SyntaxError: invalid syntax
Optional solutions:
Downgrade your python version using sudo-alternatives (check versions with update-alternatives --list python)
Correct the entire file (not viable)
Connect throug datastax or similar driver and query.
If you have the both version, set the Python2.7 as the main one. You can check the principal version using the command python -V. Then change using this command sudo ln -sf /usr/bin/python3.6 /usr/bin/python (use your path python 3x and 2x). Check if it was ok using python -V. Call the $cqlsh again.
Ps.: If necessary check the cqlsh file, if the header is correct. If it is #!/usr/bin/python3 fix to #!/usr/bin/python. You can use $find / -name cqlshto find the files.
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
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