dropbox python api import dropbox syntax error - python

Using Python 2.6.6
Trying to install dropbox python api..
Tried both ' pip install dropbox ' and ' python setup.py install '
Got this error... on import dropbox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/dropbox/__init__.py", line 3, in <module>
from . import client, rest, session
File "/usr/lib/python2.6/site-packages/dropbox/client.py", line 22, in <module>
from .rest import ErrorResponse, RESTClient, params_to_urlencoded
File "/usr/lib/python2.6/site-packages/dropbox/rest.py", line 415
utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}
^
SyntaxError: invalid syntax
am i doing anything wrong..?

It appears the code in the dropbox API uses dictionary comprehensions, which were not introduced until Python 2.7. This can also be seen on the PyPI page for this module, which lists 2.7 as the Python version needed. You will not be able to use this module unless you upgrade to Python 2.7. (According to this question it must be Python 2.7, as the API doesn't yet support Python 3.)

Related

Python fails to import SharePlum, even though it is installed correctly

Trying to use SharePlum, but getting this error when importing :-
>>> from shareplum import Office365
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myac/.local/lib/python2.7/site-packages/shareplum/__init__.py", line 5, in <module>
from .office365 import Office365 # noqa: F401
File "/home/myac/.local/lib/python2.7/site-packages/shareplum/office365.py", line 6, in <module>
from .request_helper import post
File "/home/myac/.local/lib/python2.7/site-packages/shareplum/request_helper.py", line 2, in <module>
from .errors import ShareplumRequestError
File "/home/myac/.local/lib/python2.7/site-packages/shareplum/errors.py", line 4
super().__init__(f"{msg} : {details}")
I've installed shareplum, requests, requests-ntlm, requests-toolbelt, and lxml but I keep getting this error.
Any clues?
The Shareplum version that you've installed has been configured on your python 2.7 interpreter(this is your default python version), though the version is 0.5.1, which is not supported on Python2.7: https://pypi.org/project/SharePlum/0.5.1/
Either you downgrade you Shareplum version to the one which is compatible with python2.7 i.e. https://pypi.org/project/SharePlum/0.3.0/
pip install shareplum==0.3.0
or
Make use of Python3 and install latest shareplum for that :
pip3 install shareplum
And when running terminal or the script, please make use of python3 binary instead of python

Error in importing "asammdf" in Python 3.5

I am trying to import asammdf to read MDF files but when i excute my script, there is an error from first line " import asammdf"
error is as follows :
Traceback (most recent call last):
File "<pyshell#2>", line 1, in
import asammdf
File "C:\Python\Python35-32\lib\site-packages\asammdf_init_.py", line 15, in
from .blocks.mdf_v2 import MDF2
File "C:\Python\Python35-32\lib\site-packages\asammdf\blocks\mdf_v2.py", line 4, in
from .mdf_v3 import MDF3
File "C:\Python\Python35-32\lib\site-packages\asammdf\blocks\mdf_v3.py", line 455
types.append(("", f"V{gap}"))
^
SyntaxError: invalid syntax
The library is using f-strings (see PEP 498), which were implemented in Python 3.6:
f"V{gap}"
But you are running this in Python 3.5:
File "C:\Python\Python35-32\lib\site-packages\asammdf\blocks\mdf_v3.py", line 455
You should install a newer version of Python. Python 3.5 is not supported any more (it is at end of life - see status of python branches).
Both github repo and the pypi page state that for version 5.x.y of asammdf the minimum python version is 3.6
You probably just copied the package manually to the site-packages folder

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.

Python StanfordNLP package errors on importing the library

I just installed the python stanford nlp which went fine :-
pip install stanfordnlp
from a python shell, I am trying to instantiate the package and I get the following error :-
>>> import stanfordnlp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/__init__.py", line 1, in <module>
from stanfordnlp.pipeline.core import Pipeline
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/pipeline/core.py", line 9, in <module>
from stanfordnlp.pipeline.doc import Document
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/pipeline/doc.py", line 175
return f"<{self.__class__.__name__} index={self.index};words={self.words}>"
^
SyntaxError: invalid syntax
The line:
return f"<{self.__class__.__name__} index={self.index};words={self.words}>"
Indicates that the package is intended for Python 3.6 or higher. It is returning an f-string, which was introduced in version 3.6. You are running on version 2.7.
Time to upgrade?

Pelican-quickstart not working

I followed the procedure given on the Pelican website by:
Creating a virtualenv and then source bin/activate
Installing pelican using pip install pelican
Writing pelican-quickstart
When I typed in pelican-quickstart, I got the following error:
Traceback (most recent call last):
File "/home/ashutosh_mishra/virtualenvs/pelican/bin/pelican-quickstart", line 7, in <module>
from pelican.tools.pelican_quickstart import main
File "/home/ashutosh_mishra/virtualenvs/pelican/lib/python3.2/site-packages/pelican/__init__.py", line 19, in <module>
from pelican.generators import (ArticlesGenerator, PagesGenerator,
File "/home/ashutosh_mishra/virtualenvs/pelican/lib/python3.2/site-packages/pelican/generators.py", line 14, in <module>
from jinja2 import (BaseLoader, ChoiceLoader, Environment, FileSystemLoader,
File "/home/ashutosh_mishra/virtualenvs/pelican/lib/python3.2/site-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/home/ashutosh_mishra/virtualenvs/pelican/lib/python3.2/site-packages/jinja2/environment.py", line 677
u'\xff\xff\xff\xff'.encode('iso-8859-15')
^
SyntaxError: invalid syntax
I googled the error and found Pelican 3.3 pelican-quickstart error "ValueError: unknown locale: UTF-8"', but this doesn't solve my problem.
Can anyone suggest a solution?
While the error traceback points to an issue with Jinja2 and not Pelican directly, the most likely cause is Python 3.2 — that version of Python is rather old and is no longer supported by either the Jinja2 or Pelican development teams.
Upgrading your operating system may allow your package manager to install a more recent Python version (3.4+ recommended). Alternatively, you can use a tool such as PyEnv to install the latest version of Python without having to upgrade your operating system.

Categories

Resources