Cant upgrade libraries using pip - python

Whenever I try to upgrade matplotlib using pip install matplotlib --upgrade I get the following
"setuptools must be installed to install from a source distribution"
setuptools is installed and up to date, so I'm lost.
EDIT:
If this adds any context, it started happening after I upgraded distribute
EDIT:
I solved the problem by uninstalling and reinstalling setuptools

Related

How do I prevent pip automatically installing supporting packages?

I am using python 3.6.0 within a venv. I would like to "pip install" matplotlib==2.0.0, however when I do this, pip seems to automatically grab the newest versions of all other required supporting packages for matplotlib. i.e. cycler 0.11.0, pyparsing==3.0.7, etc. These latest supporting package versions do not seem to work with the older version of matplotlib and it throws errors when attempting to import matplotlib.
How do I install matplotlib without pip attempting to install all its supporting packages automatically?
My current temporary solution is to go back and manually install each package before installing matplotlib but I'm sure I will run into this issue again so would like to find a better solution.
Pip has a built-in feature:
pip install matplotlib --no-dependencies
To exclude specific, you can put it in requirements file and pass it:
pip install --no-deps -r requirements.txt

How to deal with error message - Missing required dependencies ['numpy'] - using pycharm and anacoda

I'm learning python and want this code to work.
import pandas
df =pandas.DataFrame([[2,4,6],[10,20,30]])
print(df)
This is what I get:
File "C:\Users\User\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I'm using pycharm with anaconda environment. Hopefully I've set the environment and interpreter up right. It says I have numpy version 1.16.2 installed, however it won't let me upgrade to version 1.17.0
Tried installing, uninstalling and upgrading through packages and terminal and upgraded pip. This is what I get:
Installing collected packages: numpy
Found existing installation: numpy 1.16.4
Uninstalling numpy-1.16.4:
Successfully uninstalled numpy-1.16.4
Successfully installed numpy-1.17.0
WARNING: You are using pip version 19.1.1, however version 19.2.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\User\Documents\Python>python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl (1.4MB)
|████████████████████████████████| 1.4MB 114kB/s
Installing collected packages: pip
Found existing installation: pip 19.1.1
Uninstalling pip-19.1.1:
Successfully uninstalled pip-19.1.1
Successfully installed pip-19.2.1
I'm very new to all this and probably doing something wrong, someone please help.
enter image description here
I would advise you to try and use the Anaconda GUI Navigator, available through the standard download of Anaconda Software Bundle.
You can easily manipulate virtual environments and install/uninstall different packages, using the self-explanatory GUI. I found it very simple and a good way to start using Anaconda and Python:

Cannot uninstall 'pandas' (distutils installed project)

I have created a conda environment where I am installing all the stuff I need.
I already had installed the pandas library, but I need to upgrade it to the latest version.
However, when I try pip3 install --upgrade pandas I get the following error:
Found existing installation: pandas 0.15.2
Cannot uninstall 'pandas'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
I have tried sudo apt-get remove pandas, but this get me a message saying that the pandas package cannot be found.
In case is relevant, I am in Ubuntu 16.04 and using python 3.6.3
Though I'm unable to reproduce the error, you can try:
1) Reduce version
pip install --upgrade --force-reinstall pip==18.0
Try to re-install package
pip install xxx --disable-pip-version-check
At last, recover the latest version for pip
pip install --upgrade pip
2) pip install -I==18.0 -r requirements.txt
3) Try removing manually from 'site-packages'
These solutions were found here

How can i solve the error with installing Jupyter?

I'm new to python , i tried to install jupyter by using this command
sudo pip install jupyter
but got
Found existing installation: tornado 3.1.1
Cannot uninstall 'tornado'. It is a distutils installed project and
thus we cannot accurately determine which files belong to it which
would lead to only a partial uninstall.
I got that there is more than one version of tornado but couldn't fix it
Thanks for any help
do pip uninstall tornado
and then
do pip install tornado==4.0.0

how to install openCV_python with no import cv2 error?

I am trying to install the OpenCV-python on my mac and i have used the following:
$pip install opencv-python
which gave me the following error:
$pip install opencv-python
Collecting opencv-python
Using cached opencv_python-3.4.0.12-cp27-cp27m macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting numpy>=1.11.1 (from opencv-python)
Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: numpy, opencv-python
Found existing installation: numpy 1.8.0rc1
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Then i did try the pip install --upgrade matplotlib which didnot change anything. It just show me:
matplotlib 2.2.2 requires backports.functools-lru-cache, which is not installed.
matplotlib 2.2.2 has requirement numpy>=1.7.1, but you'll have numpy 1.8.0rc1 which is incompatible.
As I found many ways to install the openCV-python in the internet like:
https://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/
and I installed on my other mac but i got import cv2 problem alot in my codes.
I will be more than happy if anyone have a good solution or recommendation to install the openCV-python.
Thanks
In summary, macOS comes with the Python preinstalled and you should not mess with the packages installed as some system utilities depend on them.
https://docs.python.org/3.7/using/mac.html
The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.
You should take a look on either venv or virtualenv.
You can read this answer: https://stackoverflow.com/a/41972262/4796844 that will get you through the basics.
In a nutshell, to solve your problem:
$ python3 -m venv ./project-name
$ . ./project-name/bin/activate
$ pip install opencv-python
And to leave the virtual environment, simply:
$ deactivate

Categories