Python StanfordNLP package errors on importing the library - python

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?

Related

julia.install() fails on python import error

I am trying to run a Julia script from python. I have Julia 1.6.4 installed (also tried 1.7.3) and installed pip install julia from Pycharm's terminal in the virtual environment. When importing julia and then running julia.install() I get the following error message:
I use Pycharm with a virtual environment with Python 3.9.7 for my project. However, I have also tried different python versions in different virtual environments or by using the base python installed. All give the same error.
Also, ~/.julia/packages/PyCall/*/deps/build.log does not exist for me.
[ Info: Trying to import PyCall...
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\site.py", line 73, in <module>
import os
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\os.py", line 29, in <module>
from _collections_abc import _check_methods
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\_collections_abc.py", line 12, in <module>
GenericAlias = type(list[int])
TypeError: 'type' object is not subscriptable
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\<user>\PycharmProjects\<project>\venv\lib\site-packages\julia\tools.py", line 118, in install
raise PyCallInstallError("Installing", output)
julia.tools.PyCallInstallError: Installing PyCall failed.
** Important information from Julia may be printed before Python's Traceback **
Some useful information may also be stored in the build log file
`~/.julia/packages/PyCall/*/deps/build.log`.```
Julia needs to have PyCall installed
PyCall in Julia needs to be configured to use the same Python that you are using to call Julia from
For more information see this post:
I have a high-performant function written in Julia, how can I use it from 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.

dropbox python api import dropbox syntax error

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.)

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