Upgrading to latest pip caused ValueError - python

The latest upgrade to pip (using Python 3.5) causes the following error to occur for any pip command:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip3.5", line 7, in <module>
from pip import main
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/index.py", line 29, in <module>
from pip.wheel import Wheel, wheel_ext
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/wheel.py", line 32, in <module>
from pip import pep425tags
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py", line 214, in <module>
supported_tags = get_supported()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py", line 162, in get_supported
arch = get_platform()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py", line 119, in get_platform
major, minor, micro = release.split('.')
ValueError: not enough values to unpack (expected 3, got 2)
I'm even unable to upgrade or uninstall. What caused this and how can it be fixed?

I went ahead and edited
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/pep425tags.py
at line 120.
Removed the micro value, and it now works again. Not sure what happened.

Related

How do I fix pip on replit?

Whenever I run a command related to pip, or pip itself, it just returns an exception and it doesn't install anything
Here's the exception info:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/configuration.py", line 27, in <module>
from pip._internal.utils.misc import ensure_dir, enum
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 38, in <module>
from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_vendor/tenacity/__init__.py", line 522, in <module>
from pip._vendor.tenacity._asyncio import AsyncRetrying
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_vendor/tenacity/_asyncio.py", line 19, in <module>
from asyncio import sleep
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/base_events.py", line 296
future = tasks.async(future, loop=self)
I was running pip commands to install libraries on replit (because upm doesn't work well), but after uninstalling discord.py, it doesn't seem to work properly anymore
from my experience it is much better to use the pip module instead of the executable.
python3 -m pip install --upgrade pip # upgrade pip
python3 -m pip install replit # install the desired module

tensorflow installation on python docker

Running in a fresh python:3.9 docker image.
pip install tensorflow==2.8.0
import tensorflow
I get the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/tensorflow/__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/usr/local/lib/python3.9/site-packages/tensorflow/python/__init__.py", line 37, in <module>
from tensorflow.python.eager import context
File "/usr/local/lib/python3.9/site-packages/tensorflow/python/eager/context.py", line 29, in <module>
from tensorflow.core.framework import function_pb2
File "/usr/local/lib/python3.9/site-packages/tensorflow/core/framework/function_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/usr/local/lib/python3.9/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/usr/local/lib/python3.9/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/usr/local/lib/python3.9/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/usr/local/lib/python3.9/site-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 36, in <module>
_descriptor.FieldDescriptor(
File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower)
Why is that? It does not occur in Windows.
I had a similar issue with ubuntu:20.04 image and Tensorflow 2.3.0. As suggested, I downgraded to protobuf 3.19.0 (added protobuf==3.19.0 to requirements.txt file) and the issue went away

Error "Trying to re-register the builtin cmap 'cubehelix' when trying to import the python module "yt"

I installed the Python package yt simply through pip install yt. When I tried to import it, it returns the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\Anaconda3\lib\site-packages\yt\__init__.py", line 63, in <module>
from yt.fields.api import \
File "C:\Users\User\Anaconda3\lib\site-packages\yt\fields\api.py", line 19, in <module>
from . import angular_momentum
File "C:\Users\User\Anaconda3\lib\site-packages\yt\fields\angular_momentum.py", line 26, in <module>
from .vector_operations import \
File "C:\Users\User\Anaconda3\lib\site-packages\yt\fields\vector_operations.py", line 32, in <module>
from yt.geometry.geometry_handler import \
File "C:\Users\User\Anaconda3\lib\site-packages\yt\geometry\geometry_handler.py", line 29, in <module>
from yt.utilities.parallel_tools.parallel_analysis_interface import \
File "C:\Users\User\Anaconda3\lib\site-packages\yt\utilities\parallel_tools\parallel_analysis_interface.py", line 30, in <module>
from yt.data_objects.image_array import ImageArray
File "C:\Users\User\Anaconda3\lib\site-packages\yt\data_objects\image_array.py", line 18, in <module>
from yt.visualization.image_writer import write_bitmap, write_image
File "C:\Users\User\Anaconda3\lib\site-packages\yt\visualization\image_writer.py", line 26, in <module>
from .color_maps import mcm
File "C:\Users\User\Anaconda3\lib\site-packages\yt\visualization\color_maps.py", line 164, in <module>
add_colormap("cubehelix", _cubehelix_data)
File "C:\Users\User\Anaconda3\lib\site-packages\yt\visualization\color_maps.py", line 52, in add_colormap
mcm.register_cmap(name, yt_colormaps[name])
File "C:\Users\User\Anaconda3\lib\site-packages\matplotlib\cm.py", line 149, in register_cmap
raise ValueError(msg)
ValueError: Trying to re-register the builtin cmap 'cubehelix'.
I have tried to search online for solutions but it seems that almost nobody has ever addressed the same issue. I have tried to force reinstall it by pip install --upgrade --force-reinstall yt but still the same error message occurred. How should I solve it?
I googled your error and found https://mail.python.org/archives/list/yt-users#python.org/message/5C2ZTKNETGVY24QY2G6ED33CGFUPRQSW/ from a couple of months ago, which leads to https://github.com/yt-project/yt/pull/3149.
It looks like the workaround could be to downgrade Matplotlib to a version less than 3.4.0.

Install Wheel on Raspberry Pi 2 failing - IncompleteRead

I'm trying to install a wheel file and keep stumbling over the following error:
pi#raspberrypi:~ $ pip-3.2 install DsController-1.0-py3-none-any.whl
Traceback (most recent call last):
File "/usr/bin/pip-3.2", 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'
I followed the answer in this thread: How do I fix 'ImportError: cannot import name IncompleteRead'?, unfortunately without success.
The Wheel can be installed without problems under Windows.
You are not picking up the version of pip that you have installed when running pip-3.2.
As you can see, version 8.1.2 of download.py does not import IncompleteRead. However, version 1.5.6 of download.py does.
Either your copy of pip and pip-3.2 are not the same executable (and so just using pip will work), or your system has a confused import path that means you are picking up the wrong version of the pip package. In the latter case, remvoing the old installation or fixing your import path should work.

Error importing sdl2 in python3

I have a file test.py which contains only the line "import sdl2". I am running Ubuntu and have installed libsdl2 from the official repos and installed pysdl2 from pip3. I get this error:
Traceback (most recent call last):
File "./test.py", line 2, in <module>
import sdl2
File "/usr/local/lib/python3.3/dist-packages/sdl2/__init__.py", line 11, in <module>
from .events import *
File "/usr/local/lib/python3.3/dist-packages/sdl2/events.py", line 5, in <module>
from .keyboard import SDL_Keysym
File "/usr/local/lib/python3.3/dist-packages/sdl2/keyboard.py", line 7, in <module>
from .video import SDL_Window
File "/usr/local/lib/python3.3/dist-packages/sdl2/video.py", line 256, in <module>
SDL_GL_ResetAttributes = _bind("SDL_GL_ResetAttributes")
File "/usr/local/lib/python3.3/dist-packages/sdl2/dll.py", line 84, in bind_function
(funcname, self._dll))
ValueError: could not find function 'SDL_GL_ResetAttributes' in <CDLL 'libSDL2-2.0.so.0', handle 1088720 at 7fdce18f5910>
My only thought is that possibly there's some version mismatch in packages? I couldn't find anything referencing this bug after a quick googling.
This is a bug in pysdl2, which indicates that your SDL2 library version is not the latest one. (2.0.3). It has been fixed in a recent commit: https://bitbucket.org/marcusva/py-sdl2/commits/03870c58615b115abf14b11056bbcd41652873c5

Categories

Resources