ImportError: No module named packaging.version - python-import

When I tried installing Flask I got this error:
ImportError: No module named packaging.version

To fix this, I had to do:
pip install setuptools

If your Python runs on Ubuntu, try to do this:
cd /usr/local/lib/python2.7/dist-packages
mv pkg_resources/ pkg_resources_bak/
I'm not sure what package installed the "pkg_resources", it will make pip always show error.

Try this
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

As an Ubuntu 14.04 user, upgrading pip to version 9.0.1 fixed this problem for me.
Upgrading pip normally
Download get-pip.py script
Run: python get-pip.py
Upgrading/installing pip behind a corporate firewall
Download get-pip.py script, along with pip, wheel, and setuptools from pypi
Place all files in the /tmp directory
Run the following command to install pip: sudo -H python /tmp/get-pip.py --no-index --find-links=/tmp pip

In case anyone stumbles upon this problem, my solution was to change the packaging version from 22.0 to 21.3.

Related

Pipenv cannot create bin folder Ubuntu 22.04 LTS

I'm trying to setup Pipenv on Ubuntu 22.04 LTS and I used:
sudo apt install pipenv
but I get an error:
FileNotFoundError: [Errno 2] No such file or directory: '/home/foo/.local/share/virtualenvs/hello-JDpq8NmY/bin/python'
I tried to update pip with:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
Still no use.
I tried the solution suggested here and nothing changed.
The environment is there but the bin folder is missing.
I had the same problem. Remove pipenv from apt package manager and install pipenv with
pip install pipenv
After this you must set your PATH Variable to the pip dictionary.
A possible problem is related to pipenv not finding the python executable.
If this is your case is it possible to specify the path
pipenv install --python=/usr/bin/python3.10
Replace the path with desired python version
source

pipenv shell failed creating virtual environment

I am trying to create a virtual environment with the following command:
pipenv --three
But it doesn't work as the image shows:
What should I do?
I don't have virtual environment(s), like venv or virtualenv.
I had a similar problem and solved it in the following way
Uninstall PIP and pipenv, reinstall the version of python3. If not work, reinstall Python 3.7
sudo apt remove pip
sudo apt remove pipenv
sudo apt install python3-venv python3-pip
pip3 install pipenv
pipenv shell
Installing pip/setuptools/wheel with Linux Package Managers

Unable to deploy docker solution with conda-forge

I am deploying a docker solution for my application. In my docker file I used multiple conda-forge to build some containers. It worked very well for some of the containers, and give an error for the other and I am sure it is not about the package, because for the same package sometimes it work and others no.
I have tried to use pip instead of conda, but that lead to other errors since I am using conda originally for all of my configuration. Also, I read that RUN conda update --all will solve it, and for pip setup RUN pip install --upgrade setuptools
This is part of my docker file :
FROM dockerreg.cyanoptics.com/cyan/openjdk-java8:1.0.0
RUN conda update --all
RUN conda install -c conda-forge happybase=1.1.0 --yes
RUN conda install -c conda-forge requests-kerberos
RUN pip install --upgrade setuptools
RUN pip install --upgrade pip
RUN pip install kafka-python
RUN pip install requests-negotiate
The expected result is to build all containers successfully, but I am getting the following:
---> Using cache
---> 82f4cd49037d
Step 14 : RUN conda install -c conda-forge happybase=1.1.0 --yes
---> Using cache
---> c035b960aa3b
Step 15 : RUN conda install -c conda-forge requests-kerberos
---> Running in 54d869afcd00
Traceback (most recent call last):
File "/opt/conda/bin/conda", line 7, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
The command '/bin/sh -c conda install -c conda-forge requests-
kerberos' returned a non-zero code: 1
make: *** [dockerimage] Error 1
Try combining the two conda install commands into a single command: RUN conda install -c conda-forge happybase=1.1.0 requests-kerberos --yes.
I ran into a similar issue with the install commands split up; it turns out the issue was that the first caused the python version to be upgraded, which in turn was incompatible with the conda install command - causing the error you're seeing.
Another workaround I found was to add python 3.6.8 as another install arg. One of the packages I was installing must have had a python 3.7 dependency, forcing it to upgrade python, and breaking conda install.
Actually the error indicates the wrong path for conda /bin/sh
Therefore adding the proper path to the Dockerfile will solve the issue as following :
ENV PATH /opt/conda/envs/env/bin:$PATH
A good reference to related topic is here, where it suggests to create a new virtual environment within the dockerfile:
https://medium.com/#chadlagore/conda-environments-with-docker-82cdc9d25754

pip cannot install websocket-server python packge

I am inside my docker container, which is running centos6.6.1, and cannot seem to install the python package websocket-server.
pip install websocket-server
Could not find a version that satisfies the requirement websocket-server (from versions: )
I managed to get around this issue with the following command:
pip install git+http://github.com/Pithikos/python-websocket-server
but I don't like having to clone the repo in order to install the package. Any ideas how I can avoid this work around and get the first pip install to work?
I have the same problem with python package influxdb!
First what You need to do inside docker is upgrade pip and setuptools packages:
pip install -U setuptools pip
Do it inside virtualenv (if You use it).

How do I cache 'pip install' packages on CircleCI?

Is there a way to do this?
For example, I currently always install a specific version of docker-compose in the circle.yml file but I'd like this to be installed already via cache:
- sudo -H pip install -U docker-compose==1.3.3
I tried adding the following to the circle.yml but it doesn't work (nothing related to docker-compose was saved in the .cache/pip dir after the install):
cache_directories:
- /home/ubuntu/.cache/pip
Thanks to the help from Alexey (from Circle), got the solution:
Use a requirements.txt to install pip dependencies, i.e.:
docker-compose == 1.3.3
Modify the circle.yml file to add python as a dependency and do the pip install:
machine:
python:
version: 2.7.6
dependencies:
pre:
- pip install -r requirements.txt

Resources