Version conflict issue with Python packaging module - python

I was deploying OpenStack Newton devstack using stack.sh
I ran into the following issue :
Processing /opt/stack/requirements
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-2UrvLp-build/setup.py", line 29, in <module>
pbr=True)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 320, in __init__
_Distribution.__init__(self, attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 386, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2318, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/opt/stack/requirements/.venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (packaging 16.7 (/opt/stack/requirements/.venv/lib/python2.7/site-packages), Requirement.parse('packaging>=16.8'))
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-2UrvLp-build/
+inc/python:pip_install:1 exit_trap
+./stack.sh:exit_trap:487 local r=1
++./stack.sh:exit_trap:488 jobs -p
+./stack.sh:exit_trap:488 jobs=
+./stack.sh:exit_trap:491 [[ -n '' ]]
+./stack.sh:exit_trap:497 kill_spinner
+./stack.sh:kill_spinner:383 '[' '!' -z '' ']'
+./stack.sh:exit_trap:499 [[ 1 -ne 0 ]]
+./stack.sh:exit_trap:500 echo 'Error on exit'
Error on exit
+./stack.sh:exit_trap:501 generate-subunit 1486635146 55 fail
+./stack.sh:exit_trap:502 [[ -z /opt/stack/logs ]]
+./stack.sh:exit_trap:505 /home/demo/devstack/tools/worlddump.py -d /opt/stack/logs
World dumping... see /opt/stack/logs/worlddump-2017-02-09-101322.txt for details
+./stack.sh:exit_trap:511 exit 1
Looks like there is a version conflict for a package called 'packaging'.
Here's what I did - > Tried uninstall and re-installing the package by doing the following :
pip uninstall packaging
pip install --upgrade packaging
But it doesn't really help and I get the same error again.
Please help me resolve this issue, kindly be specific which command I should execute and in which directory.

I got the exact same error with devstack, here's how to fix it:
First add a global setting to log everything pip is doing. Create /etc/pip.conf with the following contents:
[global]
log = /var/log/pip.log
Then run:
sudo touch /var/log/pip.log
sudo chmod a+rw /var/log/pip.log
to make sure pip can always write to this file.
Then watch the changes related to the packaging package with:
tail -f /var/log/pip.log |grep packaging
And in parallel relaunch ./stack.sh .
At some point, in the pip logs you should see a line similar to:
Setting packaging===16.7 (from -c /opt/stack/requirements/upper-constraints.txt ...
This shows you where this requirement comes from, in this case it is from the /opt/stack/requirements/upper-constraints.txt file.
You can then manually edit the file in question to change this requirement to remove the conflict. In my case, I replaced:
packaging===16.7
by
packaging>=16.8
in /opt/stack/requirements/upper-constraints.txt
And after that the devstack installation completed without issues.
TL;DR
cd /opt/stack/requirements/
sed -i.bak s/packaging===16.7/packaging>=16.8/g upper-contraints.txt

try below commands
pip install --upgrade pip
pip install -r requirements.txt

Related

pip install throwing TypeError after updating every pip package

I ran an update to every pip package:
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
After that I'm running to a problem with: pip install pygame
Is throwing an error:
Defaulting to user installation because normal site-packages is not writeable
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "/usr/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 320, in run
requirement_set = resolver.resolve(
File "/usr/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 121, in resolve
self._result = resolver.resolve(
File "/home/user/.local/lib/python3.10/site-packages/resolvelib/resolvers.py", line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/home/user/.local/lib/python3.10/site-packages/resolvelib/resolvers.py", line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "/home/user/.local/lib/python3.10/site-packages/resolvelib/resolvers.py", line 147, in _add_to_criteria
matches = self._p.find_matches(
TypeError: PipProvider.find_matches() got an unexpected keyword argument 'identifier'
pip version: 20.3.4
python version: 3.10.1
Your using the old version of pip. upgrading to 21.3.1 might fix any issues with your current installation
To update pip for windows use:
python -m pip install --upgrade pip
For Linux use:
python3 -m pip install --upgrade pip

Can't set up virtualenv python: No module named pip

I am trying to set up a python environment on a remote computer via ssh (with no root access). I am following the instructions below:
Download the virtualenv script:
wget -O /tmp/virtualenv.py https://raw.github.com/pypa/virtualenv/master/virtualenv.py
Run the virtual env script
python /tmp/virtualenv.py $HOME/pyenv/
which will setup the environment in the "pyenv" directory in your $HOME space
Update the environment
If you are using bash (I hope you do), then you should add:
. $HOME/pyenv/bin/activate
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ioa//lib:/usr/local/lib64
to your .bashrc
And when I run python /tmp/virtualenv.py $HOME/pyenv/, I am getting the error
New python executable in /home/lht26/pyenv/bin/python
Cannot find a wheel for setuptools
Cannot find a wheel for pip
Installing setuptools, pip, wheel...
Complete output from command /home/lht26/pyenv/bin/python - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
ImportError: No module named pip
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/tmp/virtualenv.py", line 2328, in <module>
main()
File "/tmp/virtualenv.py", line 713, in main
symlink=options.symlink)
File "/tmp/virtualenv.py", line 945, in create_environment
download=download,
File "/tmp/virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/tmp/virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/lht26/pyenv/bin/python - setuptools pip wheel failed with error code 1
What should I do?
Here are the steps to run virtualenv.
First, install pip (pip3 if you have 3 version of python):
sudo apt-get install python-pip
Then run the following:
sudo pip install virtualenv
mkdir myproject
cd myproject
virtualenv venv
. venv/bin/activate

Why pip cannot install package even having permissions for both user & system repository?

When I upgrade my user's pip repository with the following command:
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
I got the following error message:
Exception:
Traceback (most recent call last):
File "/home/peng/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/peng/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/peng/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/home/peng/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/peng/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/home/peng/.local/lib/python2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/peng/.local/lib/python2.7/site-packages/pip/wheel.py", line 330, in clobber
os.utime(destfile, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/usr/local/lib/python2.7/dist-packages/easy_install.pyc'
However the file that triggers this error already has all permissions opened:
ls /usr/local/lib/python2.7/dist-packages/easy_install.pyc -l
-rwxrwxrwx 1 root staff 315 Jul 5 20:47 /usr/local/lib/python2.7/dist-packages/easy_install.pyc
Why pip is still unable to work on it? What has to be done to fix it?
I've encountered this error when running pip install by a different user than owner of python files. It's a strange (and ugly) limitation of Linux: any user with write permission can set file times to current time (touch), but only owner of file can set arbitrary times. pip/wheel is trying to set exact times, and kernel doesn't allow it.
Relevant pip issue: https://github.com/pypa/pip/issues/2125
Beta (than nuthin) solution is to change file owner or run pip as file owner user.
I am desperately looking for a better solution, please help in comments.

Set up cassandra driver (python) in Docker

I used a docker file several months ago that (1) uses base ubuntu image, (2) installs miniconda python distribution, (3) installs some python libraries using miniconda, (4) runs following commands to set up cassandra-driver for python.
RUN pip install --upgrade pip
RUN pip install cassandra-driver
This worked perfectly six months ago. But now I'm getting this exception.
Step 13 : RUN pip install cassandra-driver
---> Running in ba9955650d7c
Collecting cassandra-driver
Downloading cassandra-driver-3.0.0.tar.gz (186kB)
Complete output from command python setup.py egg_info:
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'
unable to execute 'gcc': No such file or directory
Unable to find pgen, not compiling formal grammar.
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-0XzsPv/cassandra-driver/setup.py", line 375, in <module>
run_setup(None)
File "/tmp/pip-build-0XzsPv/cassandra-driver/setup.py", line 373, in run_setup
**kw)
File "/miniconda/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 268, in __init__
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 312, in fetch_build_eggs
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 846, in resolve
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1091, in best_match
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1103, in obtain
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 379, in fetch_build_egg
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 639, in easy_install
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 669, in install_item
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 852, in install_eggs
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 1080, in build_and_install
File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 1068, in run_setup
distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0XzsPv/cassandra-driver
The command '/bin/sh -c pip install cassandra-driver' returned a non-zero code: 1
What might be going wrong? Is the installation package broken or I'm not doing it right?
The python cassandra-driver now uses Cython extensions by default since version 2.7.0, but there is an escape hatch for those who don't have easy access to the cython distribution or don't need it which might be a good option for you as well. The cython extensions do offer a boon to performance, but it might not be suitable for a lot of cases (especially where you are not doing high throughput).
From the install documentation:
By default, this package uses Cython to optimize core modules and build custom extensions. This is not a hard requirement, but is engaged by default to build extensions offering better performance than the pure Python implementation.
This build phase can be avoided using the build switch, or an environment variable:
python setup.py install --no-cython
-or-
pip install --install-option="--no-cython" <spec-or-path>
Alternatively, an environment variable can be used to switch this option regardless of context:
CASS_DRIVER_NO_CYTHON=1 <your script here>
In order to install cassandra-driver you need to compile some C source files however you don't have gcc inside your container:
unable to execute 'gcc': No such file or directory
Try to install gcc and python-dev packages before installing cassandra-driver:
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*

Cannot install netCDF4 python package on OS X

I'm trying to install netCDF4 on OS X with pip install netCDF4 and I am getting the following error:
------------------------------------------------------------
/usr/local/bin/pip run on Wed Aug 7 23:02:37 2013
Downloading/unpacking netCDF4
Running setup.py egg_info for package netCDF4
HDF5_DIR environment variable not set, checking some standard locations ..
checking /Users/mc ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4/setup.py", line 114, in <module>
raise ValueError('did not find HDF5 headers')
ValueError: did not find HDF5 headers
Complete output from command python setup.py egg_info:
HDF5_DIR environment variable not set, checking some standard locations ..
checking /Users/mc ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4/setup.py", line 114, in <module>
raise ValueError('did not find HDF5 headers')
ValueError: did not find HDF5 headers
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4
Exception information:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
status = self.run(options, args)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 256, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1042, in prepare_files
req_to_install.run_egg_info()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 236, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/util.py", line 612, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /var/folders/jj/0w0dd3n16jq4g5579g6c7h040000gn/T/pip-build/netCDF4
I already installed HDF5 to /usr/local/hdf5/ but I'm still getting the same error. I'm a new to Python so any help will be greatly appreciated.
Thank you.
You might need to set the HDF5_DIR environment variable to the location where you install HDF5; it's looking in the standard install paths and not finding the headers for HDF5 - hence at least one of your errors.
You can simply set it before calling pip:
HDF5_DIR=/usr/local/hdf5 pip install netCDF4
or export it and then call pip:
export HDF5_DIR=/usr/local/hdf5
pip install netCDF4
Simply try this procedure to install netCDF4
install HDF5 from link
install netcdf4 from link
install netcdf4-python from link
For detail visit link
If you don't need the latest version --prefer-binary flag to pip may solve it:
pip install netcdf4 --prefer-binary

Categories