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.
Related
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.
I try to install a package in Windows 10 (mingw64) and get this error:
IEUser#MSEDGEWIN10 MINGW64 /c/Users/IEUser/PycharmProjects/myapp_msi-msys/myapp_msi
$ pip install -e git+https://source.example.lan:40443/repos/myapp_common#egg=myapp_common
Obtaining myapp_common from git+https://source.example.lan:40443/repos/myapp_common#egg=myapp_common
Cloning https://source.example.lan:40443/repos/myapp_common to c:/users/ieuser/pycharmprojects/myapp_msi-msys/myapp_msi/src/myapp-common
Username for 'https://source.example.lan:40443':
Password for 'https://tguettler#source.example.lan:40443':
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:/msys64/mingw64/lib/python2.7/site-packages/setuptools/__init__.py", line 191, in <module>
monkey.patch_all()
File "C:/msys64/mingw64/lib/python2.7/site-packages/setuptools/monkey.py", line 101, in patch_all
patch_for_msvc_specialized_compiler()
File "C:/msys64/mingw64/lib/python2.7/site-packages/setuptools/monkey.py", line 164, in patch_for_msvc_specialized_compiler
patch_func(*msvc9('find_vcvarsall'))
File "C:/msys64/mingw64/lib/python2.7/site-packages/setuptools/monkey.py", line 151, in patch_params
mod = import_module(mod_name)
File "C:/msys64/mingw64/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "C:/msys64/mingw64/lib/python2.7/distutils/msvc9compiler.py", line 306, in <module>
raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
distutils.errors.DistutilsPlatformError: VC 6.0 is not supported by this module
What can I do to fix this?
I was following these instructions to set up my development environment: https://www.gtk.org/download/windows.php
Update
Just for the records, I switched from gtk to qt (PySide2) and now I can use the default Python for windows. Everything is much easier now.
In MSYS2, many of the issues are patched downstream with the MINGW-packages that go in to the pacman repository. In this case, the reason you are getting this error is that you have setuptools pip installed, instead of installed using the pacman repository. To fix this issue:
pip uninstall setuptools
pacman -S mingw-w64-x86_64-python-setuptools
or if you are using modern Python:
pip3 uninstall setuptools
pacman -S mingw-w64-x86_x64-python3-setuptools
quick thing: YES I KNOW THERE IS ANOTHER POST ON THIS, but its answers do NOT solve my issue.
So I installed this package called hangups on my raspberry pi. It ruined my pip installation and gave me the error below. However if you google this error, you will come to a post that does have a solution: re installing pip. I had done this several times; Once reinstalling pip from apt, 2nd time from get-pip.py, last by reinstalling python3. Irregardless, none of these methods solved my error (Oh and i also must mention that i did try the easy_install reinstallation of pip but that fails too). Nothing seems to work. My theory is that some repository somewhere is not updated because the error message points to some ancient version of pip (<= 2) (on my mac pip is at 9 running same version of python 3) and for some reason, pip has this dependency that isnt there just disables my pip binary. I would install them, but (lol) i dont have pip. The error is below. How do I fix this?
please comment if you need more information. Thanks!!!
/usr/local/lib/python3.4/dist-packages/requests/__init__.py:80:
RequestsDependencyWarning: urllib3 (1.22) or chardet (2.3.0) doesn't
match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python3/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name 'IncompleteRead'
Yeah ok so for future reference kids, easy_install does (like pip) have a python 3.x version. Just do sudo easy_install3 -U pip.
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)
I just tried to install Plotly using pip. I am running python from Anaconda and now anytime I attempt to run anything python I get the following errors and I have no idea how to fix it. I am running on Windows 7 64bit, Python3,4
PS Z:\> pip
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\pip-script.py", line 3, in <module>
from pip import main
File "C:\Anaconda3\lib\site-packages\pip\__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Anaconda3\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Anaconda3\lib\site-packages\pip\download.py", line 22, in <module>
from pip._vendor import requests, six
File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module>
from . import utils
File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\compat.py", line 77, in <module>
import simplejson as json
File "C:\Anaconda3\lib\site-packages\simplejson\__init__.py", line 112, in <module>
from .scanner import JSONDecodeError
File "C:\Anaconda3\lib\site-packages\simplejson\scanner.py", line 10, in <module>
c_make_scanner = _import_c_make_scanner()
File "C:\Anaconda3\lib\site-packages\simplejson\scanner.py", line 6, in _import_c_make_scanner
from simplejson._speedups import make_scanner
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
PS Z:\>
This is an interaction between Anaconda's version of pip and the latest version of simplejson (which was installed when you installed Plotly).
As a workaround,
del C:\Anaconda3\lib\site-packages\simplejson
This will allow pip and Plotly to work again. Unfortunately if you ever upgrade Plotly this problem will happen again, so we will add a workaround to the Plotly requirements.txt file that prevents this from happening in future. (Plotly only actually needs simplejson on Python 2.6 systems.)
There was an Anaconda issue open related to this that I've commented on: https://github.com/ContinuumIO/anaconda-issues/issues/238
Plotly Python API issue re: finding a workaround so this doesn't happen again (or to other users): https://github.com/plotly/python-api/issues/197
As of version 1.6.10 for the plotly package, the simplejson and ordereddict packages are no longer dependencies.
TL;DR:
Python 2.6 should use:
pip install plotly[PY2.6]
While Python 2.7, 3.3, and 3.4 should still use:
pip install plotly
More Info:
If you're already hitting the issue in this post, you'll likely need to remove the simplejson package as discussed in answer scjody gave.
The simplejson and ordereddict packages were there to have common dependencies for Python 2.6 through Python 3.4. However, since simplejson clashes with anaconda, we now have an "extras" option for the pip install.
As usual, because the version of IPython we depend on doesn't support Python 2.6, there are still two optional requirements files which install matplotlib, IPython[notebook], etc.
optional_requirements.txt
optional_requirements-2-6.txt
Quotes Notes:
Depending on the shell you're using, you may need to wrap the install target in quotes ('') when using the extras for Python 2.6:
pip install 'plotly[PY2.6]'