DistributionNotFound error after upgrading pip - runtime-error

In reading about virtualenv here I realized I didn't have pip 1.3+, so I ran pip install --upgrade pip and now when I run pip --version i get the following:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 2807, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 594, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.2.1
If it helps, or is at all relevant, my $PATH looks like this:
/usr/local/bin:/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Also, which pip gives me /usr/local/bin/pip.
Not sure what to do about the error. Thanks.

The brutal way:
Assuming you are using homebrew for Mac (because I see /usr/local/Cellar), I suggest to
remove (or backup) /usr/local/lib/python2.7, and
brew rm python && brew install python.
This will definitely install pip 1.3.3 alongside of python. Your distribute will also be 0.6.35.
The soft way:
From /usr/local/lib/python2.7/site-packages just remove:
easy-install.pth
pip-1.2.1-py2.7.egg or other versions of pip you have.
distribute-0.6.34-py2.7.egg or other versions
Then, brew rm python && brew install python. This will leave all your other bindings from brew and installed stuff intact. Python, pip and distribute will be replaced with up-to-date versions.
additionally:
Please check that you don't have a distribute or setuptools or pip located in /Library/Python/2.7/site-packages. That dir is re-used by all python 2.7 versions (brewed or from OS X) and will interferre with the pip/distribute already installed by Homebrew.

I happened to get to a similar state after upgrading from OS X Lion to Mountain Lion today.
The other proposed solutions either do not work, or replace the Apple version of Python with the brew version, which I'm not sure is what saclark asked for.
What I did to get it fixed is install distribute manually, thus getting easy_install back to work, and then install pip with it.
The commands are:
$ curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.45.tar.gz
$ tar -xzvf distribute-0.6.45.tar.gz
$ cd distribute-0.6.45
$ sudo python setup.py install
$ sudo easy_install pip
If the link does not work, you can alway find newer versions of distribute here.

I got similar problem today. After some research, I solved it by reinstalling pip using this:-
python -m pip install --upgrade --force-reinstall pip
Hope somebody would find it helpful.

As an aside, there's an easier way to do it (I just encountered this).
Edit /usr/local/bin/pip and change the references to version number (so below you'd want to change '1.5.6' to whatever version number you're using):
#!/usr/local/opt/python/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.5.6','console_scripts','pip'
__requires__ = 'pip==1.5.6'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
)
then you may be completely good at that point.

I wanna find out at where pip 1.2.1 is required, but I don't have so much time... so I just downgrade pip to 1.2.1. It can't be helped for a while, till pip or distribute package is modified.
How to do this? just type this in console(I hope your distribute package is well):
easy_install pip==1.2.1

There is no need to uninstall python and install it back. Get the latest distribute package installed and then update pip with it should do the trick.
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py
sudo easy_install -U pip

The correct way to fix modern version (6.x) of pip in 2 steps
Delete the pip package in Python's site-package. For Homebrew Python 2.7, do this:
rm -r /usr/local/lib/python2.7/site-packages/pip
Follow the instructions on the official pip documentation site to reinstall it. For short:
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
For pip 6.x, there's no need to install the legacy distribute package. Just setuptools, which will be installed by default via the get-pip.py script mentioned above.

Hm.. puzzling. Wonder where that 1.2.1 comes from. Just out of curiosity, could you post the contents of /usr/local/bin/pip? Should only be a couple of lines.
You could try updating pip (again) with distribute, and maybe also distribute itself..
easy_install --upgrade distribute
easy_install --upgrade pip

Related

I can't install lableImg Annotation tool in M1 Mac

While installing LabelImg in M1 Mac using below command
pip install pyqt5 lxml
This is the error I got
ERROR: pyqt5 from https://files.pythonhosted.org/packages/7c/5b/e760ec4f868cb77cee45b4554bf15d3fe6972176e89c4e3faac941213694/PyQt5-5.14.0.tar.gz#sha256=0145a6b7de15756366decb736c349a0cb510d706c83fda5b8cd9e0557bc1da72 has a pyproject.toml file that does not comply with PEP 518: 'build-system.requires' contains an invalid requirement: 'sip >=5.0.1 <6'
How to install lableImg annotation tool in M1 Mac?
I got it to work by using the following commands
brew install pyqt#5
pip install labelimg
And that's it, it just works
You just need to type labelimg in the Terminal and the app will start running
I don't know why they don't tell you this in the installation guide
Alrighty!
On MacOS Monterey, none of the other solutions posted here solved this problem for me. However, I managed to easily solve the issue, without a virtual environment or too much fiddling about like so:
Firstly, you have to download all labelImg packages from this link:
https://github.com/tzutalin/labelImg#macos
(You can download it as a .zip file or clone it)
Unzip and then in your terminal cd into whatever directory you downloaded the above files to.
Then run the following commands in order:
pyrcc5 -o libs/resources.py resources.qrc
Then,
pip3 install lxml
Finally,
python3 labelImg.py
It should run without an issue now.
You can go one of two ways:
Using brew:
You can use homebrew to install the dependencies - like qt and libxml2. This will let your package manager handle everything and generally should solve the problem with the . Then you can run
python3 labelimg.py
Using Virtual Environments:
This is the more recommended way to go about in such cases. You can use conda, pipenv or venv to create a virtual environment which is isolated from your system python installation. Then you can try to install it as explained in the README.rst in the root of the repository:
brew install python3
pip3 install pipenv
pipenv run pip install pyqt5==5.12.1 lxml
pipenv run make qt5py3
pipenv run python3 labelImg.py
[Optional] rm -rf build dist; python setup.py py2app -A;mv "dist/labelImg.app" /Applications
You can try the two methods and and get back with the errors if there are any.
This is my note.
I just succeed on my Mac M1 Chip
CHECK THIS OUT!
Installation of labelimg on mac m1 chip
my first reference
my second reference
First, you must use terminal with rosetta version
Then, you already have python3
Then...
[Done]
# check where python3 is
$ where python3
# create env
$ /usr/bin/python3 -m venv env
# check env is
$ where env
# activate env list
$ source env/bin/activate
# updated to the newest
$ pip install --upgrade pip
# installation of PyQt5
$ pip install PyQt5
# start to run labelImg.py
$ cd Documents/repos/labelImg
$ pip3 install pyqt5 lxml
$ make qt5py3
# [run ok!!]
$ python3 labelImg.py
Using Conda
Create a virtual environment in conda and activate it
conda create -n venv
conda activate venv
Install pyqt using conda
conda install pyqt
Install lxml using pip
pip install lxml
Change directory to the downloaded/cloned labelImg folder
cd path/to/labelImg/folder/
Make qt5py3
make qt5py3
Run LabelImg
python labelImg.py

Installing Sqlite3 on Ubuntu 14.04 for Python3.6

I have a virtual environment set up with python 3.6. I'm trying to install sqlite3 (I built python from source) and am having trouble doing so. (I need sqlite3 for tensorboard)
After some digging I found an approach:
sudo apt-get install libsqlite3-dev
Now in the downloaded python source rebuild and install python with the following command:
./configure --enable-loadable-sqlite-extensions && make && sudo make install
The issue is I cannot run the first command. Running the first command gives me the error "download failed Oracle JDK 6 is NOT installed." Therefore I downloaded the libsqlite3-dev file.
My question is, where should this be placed before I can run step 2.
I've looked around for a solution for a few hours now ans seem to be at a loss. Any help would be really appreciated with either solving this approach or proposing another approach.
Use Anaconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
conda create -n envsq python=3.7
source activate envsq
python
And you can import sqlite3 with no issues.

Error while install airflow: By default one of Airflow's dependencies installs a GPL

Getting the following error after running pip install airflow[postgres] command:
> raise RuntimeError("By default one of Airflow's dependencies installs
> a GPL "
>
> RuntimeError: By default one of Airflow's dependencies installs a GPL
> dependency (unidecode). To avoid this dependency set
> SLUGIFY_USES_TEXT_UNIDECODE=yes in your environment when you install
> or upgrade Airflow. To force installing the GPL version set
> AIRFLOW_GPL_UNIDECODE
I am trying to install in Debian 9
Try the following:
export AIRFLOW_GPL_UNIDECODE=yes
OR
export SLUGIFY_USES_TEXT_UNIDECODE=yes
Using export makes the environment variable available to all the subprocesses.
Also, make sure you are using pip install apache-airflow[postgres] and not pip install airflow[postgres]
Which should you use: if using AIRFLOW_GPL_UNIDECODE, airflow will install a dependency that is under GPL license, which means you won't be able to distribute your resulting application commercially. If that's a problem for you, go for SLUGIFY_USES_TEXT_UNIDECODE.
If you are installing using sudo run one of these commands:
sudo AIRFLOW_GPL_UNIDECODE=yes pip3 install apache-airflow
OR
sudo SLUGIFY_USES_TEXT_UNIDECODE=yes pip3 install apache-airflow
NOTE: If pip3 (python3) does not work for you, try pip command.
The pip command can be pointing to python2 or python3 installation depending on your system. Verify this by running pip --version.
Windows users can use the command below before installing apache-airflow:
$ set AIRFLOW_GPL_UNIDECODE=yes
then
$ pip install apache-airflow
In case you are installing the airflow on Windows and through Python terminal then you need to write this:
Set SLUGIFY_USES_TEXT_UNIDECODE=yes
pip install apache-airflow[postgres]
It worked with me after I struggled with trying many other options. Hope this will work with you too.
Below command should install apache-airflow and lets you pull changes into PyCharm for building DAGs and coding for Airflow.
SLUGIFY_USES_TEXT_UNIDECODE=yes
pip install apache-airflow
Also, if you are installing using sudo you can use:
export AIRFLOW_GPL_UNIDECODE='yes'
sudo -E pip3 install apache-airflow
(or use SLUGIFY_USES_TEXT_UNIDECODE)
Run the following command in your python terminal: SLUGIFY_USES_TEXT_UNIDECODE=yes pip install apache-airflow==1.10.0
Use below command to install apache-airflow
sudo SLUGIFY_USES_TEXT_UNIDECODE=yes \
pip install apache-airflow[async,devel,celery,crypto,druid,gcp_api,jdbc,hdfs,hive,kerberos,ldap,password,postgres,qds,rabbitmq,s3,samba,slack]

answer yes's to repeated unix prompts [duplicate]

I'm trying to uninstall all django packages in my superuser environment to ensure that all my webapp dependencies are installed to my virtualenv.
sudo su
sudo pip freeze | grep -E '^django-' | xargs pip -q uninstall
But pip wants to confirm every package uninstall, and there doesn't seem to be a -y option for pip. Is there a better way to uninstall a batch of python modules? Is rm -rf .../site-packages/ a proper way to go? Is there an easy_install alternative?
Alternatively, would it be better to force pip to install all dependencies to the virtualenv rather than relying on the system python modules to meet those dependencies, e.g. pip --upgrade install, but forcing even equally old versions to be installed to override any system modules. I tried activating my virtualenv and then pip install --upgrade -r requirements.txt and that does seem to install the dependencies, even those existing in my system path, but I can't be sure if that's because my system modules were old. And man pip doesn't seem to guarantee this behavior (i.e. installing the same version of a package that already exists in the system site-packages).
starting with pip version 7.1.2 you can run pip uninstall -y <python package(s)>
pip uninstall -y package1 package2 package3
or from file
pip uninstall -y -r requirements.txt
Pip does NOT include a --yes option (as of pip version 1.3.1).
WORKAROUND: pipe yes to it!
$ sudo ls # enter pw so not prompted again
$ /usr/bin/yes | sudo pip uninstall pymongo
If you want to uninstall every package from requirements.txt,
pip uninstall -y -r requirements.txt
on www.saturncloud.io, Jupiter notebooks one can use like this:
!yes | pip uninstall tensorflow
!yes | pip uninstall gast
!yes | pip uninstall tensorflow-probability
Alternatively, would it be better to force pip to install all dependencies to the virtualenv rather than relying on the system python modules to meet those dependencies,
Yes. Don't mess too much with the inbuilt system installed packages. Many of the system packages, particularly in OS X (even the debian and the derived varieties) depend too much on them.
pip --upgrade install, but forcing even equally old versions to be installed to override any system modules.
It should not be a big deal if there are a few more packages installed within the venv that are already there in the system package, particularly if they are of different version. Thats the whole point of virtualenv.
I tried activating my virtualenv and then pip install --upgrade -r requirements.txt and that does seem to install the dependencies, even those existing in my system path, but I can't be sure if that's because my system modules were old. And man pip doesn't seem to guarantee this behavior (i.e. installing the same version of a package that already exists in the system site-packages).
No, it doesn't install the packages already there in the main installation unless you have used the --no-site-packages flag to create it, or the required and present versions are different..
Lakshman Prasad was right, pip --upgrade and/or virtualenv --no-site-packages is the way to go. Uninstalling the system-wide python modules is bad.
The --upgrade option to pip does install required modules in the virtual env, even if they already exist in the system environment, and even if the required version or latest available version is the same as the system version.
pip --upgrade install
And, using the --no-site-packages option when creating the virtual environment ensures that missing dependencies can't possibly be masked by the presence of missing modules in the system path. This helps expose problems during migration of a module from one package to another, e.g. pinax.apps.groups -> django-groups, especially when the problem is with load templatetags statements in django which search all available modules for templatetags directories and the tag definitions within.
pip install -U xxxx
can bypass confirm

ImportError: No module named haystack

If I install the latest stable 1.2.7 django-haystack with sudo pip install django-haystack, it works fine. But after uninstalling it and installing the very latest dev version 2.0.0 BETA instead as suggested on the main page:
pip install -e git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack
Despite the success messages below, it seems like it is not properly installed:
Obtaining django-haystack from git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack
Cloning https://github.com/toastdriven/django-haystack.git (to master) to ./src/django-haystack
Running setup.py egg_info for package django-haystack
Installing collected packages: django-haystack
Running setup.py develop for django-haystack
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
Creating /usr/local/lib/python2.7/dist-packages/django-haystack.egg-link (link to .)
Adding django-haystack 2.0.0-beta to easy-install.pth file
Installed /home/kave/projects/cb/src/django-haystack
Successfully installed django-haystack
Cleaning up...
because when I go into the django shell environment and do a
>>> from haystack import indexes
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named haystack
I have followed the instructions and have
INSTALLED_APPS = (... 'haystack',) in there
I had this problem before, but could never solve it. sudo pip install default works fine, but as long as I get the latest Git version, my django doesn't seem to see it.
What could I be missing?
Many Thanks for your advice,
UPDATE
Apologies, but it seems the error is happening only within Aptana Studio 3.0. In Django Shell I can do the import after all. I am still dazzled, as this should be the same. Why can Aptana see the libraries when installing with sudo pip install django-haystack but not if using latest Git version? What could go wrong there please?
UPDATE 2
full sys.path
['/home/kaveh/projects/cb', '/usr/local/lib/python2.7/dist-packages/requests-0.13.9-py2.7.egg', '/home/kaveh/projects/cb/src/django-haystack', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
I finally got it working.
As I said the problem is pip install -e git+https://github.com/toastdriven/django-haystack.git#master#egg=django-haystack is apparently not working.
I simply uninstalled it and made sure its deleted.
Then I simply downloaded the source as zip file, extracted it and
python setup.py build
sudo python setup.py install
This way it will guaranteed be working. Hope this helps someone.

Resources