"SyntaxError: invalid syntax" while installing Setuptools - python

I needed to install Setuptools for a project I was doing, and I had to download Setuptools through a .tar file (don't ask), but when ran the command I needed to use to install it:
C:\Users\myname\Downloads\setuptools-51.1.1>py -2 setup.py install
It ended up with a SyntaxError:
Traceback (most recent call last):
File "setup.py", line 7, in <module>
import setuptools
File "C:\Users\myname\Downloads\setuptools-51.1.1\setuptools\__init__.py", line 16, in <module>
import setuptools.version
File "C:\Users\myname\Downloads\setuptools-51.1.1\setuptools\version.py", line 1, in <module>
import pkg_resources
File "C:\Users\myname\Downloads\setuptools-51.1.1\pkg_resources\__init__.py", line 1365
raise SyntaxError(e) from e
^
SyntaxError: invalid syntax
I'm using Python 2.7.
Why is it showing the error, and how can I fix it?
Edit:
When I looked into the __init__.py file, I found that there was something called an "invalid marker":
try:
marker = packaging.markers.Marker(text)
return marker.evaluate()
except packaging.markers.InvalidMarker as e:
raise SyntaxError(e) from e

The last version of setuptools to support Python 2.7 was 44.1.1 (Jan 2020). See the changelog.
Upgrade your Python version in order to use setuptools 51.1.1.

Related

How to install packages on portable python

Good morning,
i'm trying to install a package on portable python. I found that i do not have the easy_install.exe file, I just have the easy_install.py file.
I tried the following from prompt_CDOS:
1)
C:\Software\Portable Python 3.2.5.1>app\py
thon.exe textract-1.6.1.tar\textract-1.6.1\setup.py
Traceback (most recent call last):
File "textract-1.6.1.tar\textract-1.6.1\setup.py", line 4, in <module>
from setuptools import setup
File "C:\Software\Portable Python 3.2.5.
1\app\lib\site-packages\setuptools\__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "C:\Software\Portable Python 3.2.5.
1\app\lib\site-packages\setuptools\extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Software\Portable Python 3.2.5.
1\app\lib\site-packages\setuptools\dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
2)
C:\Software\Portable Python 3.2.5.1>App\py
thon.exe App\easy_install.py textract-1.6.1.tar\textract-1.6.1\setup.py
Traceback (most recent call last):
File "App\easy_install.py", line 4, in <module>
from setuptools.command.easy_install import main
File "C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
any suggestion?
thanks
The syntax
except ValueError, e:
^
SyntaxError: invalid syntax
is for Python 2. The error is from the file C:\Software\Portable Python 3.2.5.
1\App\lib\site-packages\setuptools\dist.py. It seems you have a wrong version of setuptools installed. You have setuptools for Py2 but you need setuptools for Py3.

pip install * have "Syntax error"

A have a problem where try to install module from pip like:
Install packages failed: Error occurred when installing package lxml.
The following command was executed:
packaging_tool.py install --build-dir C:\Users\User\AppData\Local\Temp\pycharm-packaging2629877941665473195.tmp lxml
The error output of the command:
C:\Python32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 3.1\helpers\packaging_tool.py", line 125, in main
retcode = do_install(pkgs)
File "C:\Program Files (x86)\JetBrains\PyCharm 3.1\helpers\packaging_tool.py", line 56, in do_install
import pip
File "C:\Python32\lib\site-packages\pip\__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python32\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Python32\lib\site-packages\pip\download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "C:\Python32\lib\site-packages\pip\utils\ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "C:\Python32\lib\site-packages\pip\_vendor\progress\bar.py", line 48
empty_fill = u'\u2219'
^
SyntaxError: invalid syntax
How fix this? I can not install any module or rollback pip.
Python 3.2
Pip 8.1.1
You need to upgrade your Python. Python 3.2 does not support Unicode string literals with the u"..." syntax (the idea was that these are not needed anymore because all string literals are Unicode in Python 3.x). This is why you are getting the error.
In Python 3.3, this feature was restored to make it easier to write code that runs on either Python 2.x or 3.x and clearly PIP is taking advantage of this.
Indeed, the documentation for PIP 8.1.1 mentions that it needs Python 3.3 or later.

ocdev won't run: SyntaxError: invalid Syntax

I can't get the ocdev tool to run. when I try running it i receive "SyntaxError: invalid syntax" with some code.
My guess is maybe wrong python version? Since python --version outputs 2.7.3.
I also have python3 installed but it's not the standard version. I installed ocdev using pip-3.2. I already tried reinstalling it multiple times. I also have python3-jinja2 installed. I'm running debian 7.8.
Here is the whole error:
Traceback (most recent call last):
File "/usr/local/bin/ocdev", line 9, in <module>
load_entry_point('ocdev==0.1.2', 'console_scripts', 'ocdev')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/ocdev/application.py", line 20, in <module>
from ocdev.plugins import PLUGINS
File "/usr/local/lib/python3.2/dist-packages/ocdev/plugins/__init__.py", line 1, in <module>
from ocdev.plugins.startapp.startapp import StartApp
File "/usr/local/lib/python3.2/dist-packages/ocdev/plugins/startapp/startapp.py", line 7, in <module>
from jinja2 import Environment, FileSystemLoader
File "/usr/local/lib/python3.2/dist-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/usr/local/lib/python3.2/dist-packages/jinja2/environment.py", line 639
u'\xff\xff\xff\xff'.encode('iso-8859-15')
^
SyntaxError: invalid syntax
In order to get ocdev to work with Python 3.2 you need to install legacy versions of Jinja2(source) and MarkupSafe(source). This is because the newer versions require Python 3.3.
To do the proper install follow the regular setup guide and use the following pip/pip3 commands:
pip install -Iv Jinja2==2.6
pip install -Iv MarkupSafe==0.15
pip install ocdev
I also reported this in the ocdev GitHub repository here.
It looks like you're running Python 3.2.
To use the u'unicode' syntax with Python 3 you'll need at least Python 3.3. (see What's New In Python 3.3)

Error installing ckanclient on Python 3.3 using pip

I'm trying to install ckanclient on Python 3.3 using pip. The command line I'm using is:
c:\Python33\Scripts>pip install ckanclient
I'm getting:
Downloading/unpacking ckanclient
Downloading ckanclient-0.10.tar.gz
Running setup.py (path:c:\users\lgms\appdata\local\temp\pip_build_lgms\ckanclient\setup.py) egg_info for package ckanclient
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "c:\users\lgms\appdata\local\temp\pip_build_lgms\ckanclient\setup.py"
, line 8, in <module>
from ckanclient import __version__, __description__, __long_description_
_, __license__
File ".\ckanclient\__init__.py", line 100
except HTTPError, inst:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "c:\users\lgms\appdata\local\temp\pip_build_lgms\ckanclient\setup.py", li
ne 8, in <module>
from ckanclient import __version__, __description__, __long_description__, _
_license__
File ".\ckanclient\__init__.py", line 100
except HTTPError, inst:
^
SyntaxError: invalid syntax
----------------------------------------
Cleaning up...
I need a clue about what is happening there and how to fix it. My OS is Windows 7 Pro, I'm using the standard Python distribution (I also have Anaconda Python installed, but this doesn't look like a version conflict).
The full error log is in: http://pastebin.com/NgFFCrcK
ckanclient, as well as CKAN itself, is not compatible with Python 3. You'll need 2.7.
Another hint: ckanclient is deprecated, see https://github.com/okfn/ckanclient-deprecated. However, if for some reason you really need it please do not use the rather old pip (e.g. pypi) version, but the up-to-date one from github.

pip install rauth fails : syntax error

I just installed Python 3.3 and then I tried to install rauth by issuing the command:
pip install rauth
and I get this error:
Downloading/unpacking rauth
Running setup.py egg_info for package rauth
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\pipul\appdata\local\temp\pip-build-pipul\rauth\setup.py", l
ine 4, in <module>
from rauth import __version__
File ".\rauth\__init__.py", line 30, in <module>
from .service import OAuth1Service, OAuth2Service, OflyService
File ".\rauth\service.py", line 23
except KeyError, e: # pragma: no cover
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "c:\users\pipul\appdata\local\temp\pip-build-pipul\rauth\setup.py", line 4, in <module>
from rauth import __version__
File ".\rauth\__init__.py", line 30, in <module>
from .service import OAuth1Service, OAuth2Service, OflyService
File ".\rauth\service.py", line 23
except KeyError, e: # pragma: no cover
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1 in c:\users\pipul\appd
ata\local\temp\pip-build-pipul\rauth
Storing complete log in C:\Users\pipul\pip\pip.log
## Heading ##c:\Python33\Scripts>
Similarly installing oauth2 also fails. But installing selenium succeeds.
Now what could be the thing that is causing this failure?
Thanks in advance.
Like many packages, rauth currently does not support Python 3. However, it looks like there is a branch where they are working on it. See here.
In general, you may have more luck installing packages if you use Python 2.7.

Categories