In Amazon Linux, unable to install pandas and numpy in virtualenv - python

I have been trying to install pandas and numpy in my virtualenv. The box is an Amazon Linux AMI instance. This is my command log:
Activate venv and check packages
[ec2-user#ip-0-0-0-0 www]$ source datasci_venv/bin/activate
(datasci_venv) [ec2-user#ip-0-0-0-0 www]$ pip freeze
Django==1.11
requests==2.20.1
Then using pip install to install pandas and numpy. Note that when installing Django and requests, they were successfully installed:
(datasci_venv) [ec2-user#ip-0-0-0-0 www]$ pip install pandas && pip install numpy
Collecting pandas
Using cached https://files.pythonhosted.org/packages/e1/d8/feeb346d41f181e83fba45224ab14a8d8af019b48af742e047f3845d8cff/pandas-0.23.4-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: pytz>=2011k in ./datasci_venv/lib/python3.6/dist-packages (from pandas) (2018.7)
Collecting numpy>=1.9.0 (from pandas)
Using cached https://files.pythonhosted.org/packages/ff/7f/9d804d2348471c67a7d8b5f84f9bc59fd1cefa148986f2b74552f8573555/numpy-1.15.4-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: python-dateutil>=2.5.0 in ./datasci_venv/lib/python3.6/dist-packages (from pandas) (2.7.5)
Requirement already satisfied: six>=1.5 in ./datasci_venv/lib/python3.6/dist-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)
Installing collected packages: numpy, pandas
Successfully installed numpy-1.15.4 pandas-0.23.4
Collecting numpy
Using cached https://files.pythonhosted.org/packages/ff/7f/9d804d2348471c67a7d8b5f84f9bc59fd1cefa148986f2b74552f8573555/numpy-1.15.4-cp36-cp36m-manylinux1_x86_64.whl
tabula-py 1.3.0 requires pandas, which is not installed.
Installing collected packages: numpy
Successfully installed numpy-1.15.4
So it seems that they are correctly installed, since there are no error messages. However, when I check my packages again, they are not there:
(datasci_venv) [ec2-user#ip-0-0-0-0 www]$ pip freeze
Django==1.11
requests==2.20.1
And hence I decided to check which command I am using but it says I'm using the programs in the venv:
(datasci_venv) [ec2-user#ip-0-0-0-0 www]$ which pip
/var/www/datasci_venv/bin/pip
(datasci_venv) [ec2-user#ip-0-0-0-0 www]$ which python
/var/www/datasci_venv/bin/python
(datasci_venv) [ec2-user#ip-0-0-0-0 www]$
Hence, I'm kinda lost on what to do and check. Any help or solution is appreciated.

I had the same issue, it appears that pip is installing the package in the lib64 folder of your virtualenv rather than on the lib folder. You need to force the target folder by doing this:
pip install --target datasci_venv/lib/python3.6/dist-packages/ numpy
Hope this help!

Related

Spyder (pip installed) doesn't start anymore with the error: undefined symbol: _ZdaPvm, version QT_5

On Ubuntu 22.04 (5.15.0-43-generic) I freshly updated spyder using pip as follow:
$ sudo -H pip3 install --upgrade spyder
everything went fine, but it throws this error when I start spyder now:
$ spyder
Traceback (most recent call last):
File "/usr/local/bin/spyder", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/spyder/app/start.py", line 248, in main
from spyder.app import mainwindow
File "/usr/local/lib/python3.10/dist-packages/spyder/app/mainwindow.py", line 57, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "/usr/local/lib/python3.10/dist-packages/qtpy/QtWebEngineWidgets.py", line 29, in <module>
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ImportError: /usr/local/lib/python3.10/dist-packages/PyQt5/Qt5/lib/libQt5Network.so.5: undefined symbol: _ZdaPvm, version Qt_5
Some more info:
$ python3 --version
Python 3.10.4
$ pip list | grep -i pyqt
PyQt5 5.15.6
PyQt5-Qt5 5.15.2
PyQt5-sip 12.11.0
PyQtWebEngine 5.15.5
PyQtWebEngine-Qt5 5.15.2
$ pip list | grep -i spyder
pyls-spyder 0.4.0
spyder 5.3.2
spyder-kernels 2.3.2
And I'm not able to uninstall PyQt5:
$ sudo -H pip uninstall pyqt5
Found existing installation: PyQt5 5.15.6
ERROR: Cannot uninstall PyQt5 5.15.6, RECORD file not found. Hint: The package was installed by sip-build.
The last line being printed in red in the terminal.
From that point, I'm not able to find relevant information on how to debug this in order to make spyder work again.
What could I do to fix this error?
Have you looked at this? This is exactly why you shouldn't use sudo pip install. Library versions get borked, inconsistencies arise, and stuff doesn't work.
Use sudo pip (for the last time) to uninstall Spyder and PyQT5, then reinstall the relevant packages using apt. Finally, upgrade Spyder using pip install --user (no sudo!). Everything should work okay after that.
Okay, this fixed it for me:
$ sudo -H pip3 install --force-reinstall spyder
it will probably throw some errors such as:
Attempting uninstall: PyQtWebEngine
Found existing installation: PyQtWebEngine 5.15.5
ERROR: Cannot uninstall PyQtWebEngine 5.15.5, RECORD file not found. Hint: The package was installed by sip-build.
which, if you try to update it individually will show:
$ sudo -H pip3 install -U PyQtWebEngine
Requirement already satisfied: PyQtWebEngine in /usr/lib/python3/dist-packages (5.15.5)
Collecting PyQtWebEngine
Using cached PyQtWebEngine-5.15.6-cp37-abi3-manylinux1_x86_64.whl (230 kB)
Requirement already satisfied: PyQt5>=5.15.4 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.7)
Requirement already satisfied: PyQtWebEngine-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (12.11.0)
Requirement already satisfied: PyQt5-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQt5>=5.15.4->PyQtWebEngine) (5.15.2)
Installing collected packages: PyQtWebEngine
Attempting uninstall: PyQtWebEngine
Found existing installation: PyQtWebEngine 5.15.5
ERROR: Cannot uninstall PyQtWebEngine 5.15.5, RECORD file not found. Hint: The package was installed by sip-build.
Therefore, in that case, run the installation using the --ignore-installed flag on the incriminated package, which should install it without any trouble:
$ sudo -H pip3 install --ignore-installed PyQtWebEngine
Collecting PyQtWebEngine
Using cached PyQtWebEngine-5.15.6-cp37-abi3-manylinux1_x86_64.whl (230 kB)
Collecting PyQtWebEngine-Qt5>=5.15.0
Using cached PyQtWebEngine_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (67.5 MB)
Collecting PyQt5>=5.15.4
Using cached PyQt5-5.15.7-cp37-abi3-manylinux1_x86_64.whl (8.4 MB)
Collecting PyQt5-sip<13,>=12.11
Using cached PyQt5_sip-12.11.0-cp310-cp310-manylinux1_x86_64.whl (359 kB)
Collecting PyQt5-Qt5>=5.15.0
Using cached PyQt5_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (59.9 MB)
Installing collected packages: PyQtWebEngine-Qt5, PyQt5-Qt5, PyQt5-sip, PyQt5, PyQtWebEngine
Successfully installed PyQt5-5.15.7 PyQt5-Qt5-5.15.2 PyQt5-sip-12.11.0 PyQtWebEngine-5.15.6 PyQtWebEngine-Qt5-5.15.2
After what the above-mentioned error will never show up again. Here as an example:
$ sudo -H pip3 install -U PyQtWebEngine
Requirement already satisfied: PyQtWebEngine in /usr/local/lib/python3.10/dist-packages (5.15.6)
Requirement already satisfied: PyQtWebEngine-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (12.11.0)
Requirement already satisfied: PyQt5>=5.15.4 in /usr/local/lib/python3.10/dist-packages (from PyQtWebEngine) (5.15.7)
Requirement already satisfied: PyQt5-Qt5>=5.15.0 in /usr/local/lib/python3.10/dist-packages (from PyQt5>=5.15.4->PyQtWebEngine) (5.15.2)
Repeat the same procedure for all offending packages.
Finally update spyder:
$ sudo -H pip3 install --force-reinstall spyder
And voila. A working spyder should be available.
As an aside: please note the -H option after sudo. This install packages under /usr/local/lib/python3.xx/dist-packages which will normally not conflict with apt system wide installed packages (which are under /usr/lib/python3/dist-packages) and which you definitely don't want to touch another what than with apt actually!
I'm using this to avoid installing the same packages on a user-basis by invoking pip without sudo, which will install them under ~/.local/lib/python3.10/site-packages/ for every user on the machine.

Librosa installation pip fail

I am trying to install librosa by pip install librosa on the mac terminal, pip3 also has the same problem. It also gets stuck when I try to install scikit-learn.
Doesn't go any further than:
Collecting librosa
Using cached librosa-0.8.1-py3-none-any.whl (203 kB)
Collecting packaging>=20.0
Using cached packaging-21.0-py3-none-any.whl (40 kB)
Requirement already satisfied: numpy>=1.15.0 in /opt/homebrew/lib/python3.9/site-packages (from librosa) (1.21.0)
Requirement already satisfied: scipy>=1.0.0 in /opt/homebrew/lib/python3.9/site-packages (from librosa) (1.7.0)
Collecting numba>=0.43.0
Using cached numba-0.53.1.tar.gz (2.2 MB)
Collecting resampy>=0.2.2
Using cached resampy-0.2.2.tar.gz (323 kB)
Requirement already satisfied: soundfile>=0.10.2 in /opt/homebrew/lib/python3.9/site-packages (from librosa) (0.10.3.post1)
Collecting scikit-learn!=0.19.0,>=0.14.0
Using cached scikit-learn-0.24.2.tar.gz (7.5 MB)
Installing build dependencies ... \
I am very new at this, please help I just want to draw some spectrograms.
python --version
Python 2.7.16
python3 --version
Python 3.9.6
pip --version
pip 21.1.3 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
It might be useful for you to work in a virtual environment. If you are trying to install with python 3.9 there may be a number of dependency issues, so using a lower version may also solve your issues. However, do try to with a conda environment as this will allow you to more easily keep track of install packages etc. Here are the install instructions:
After the install you can create a conda environment with a lower python version:
conda create -n "py38" python=3.8 ipython
Activate the environment:
conda activate py38
Install librosa:
conda install -c conda-forge librosa

Can't install new packages or list existing packages in virtual environment with pip

Update / Solution:
Found a fix/workaround in the answer to this question:
Pip installing packages to global site-packages when inside virtual environment.
Like the OP of that question, I'm also running Manjaro Linux with the latest updates.
When trying to install the django import_export module with pip install django-import-export into my virtual environment, it indicates that it was successfully installed, however, when I try to use the import_export module in my project, I receive an error: ModuleNotFoundError: No module named 'import_export'. I'm also unable to list any previously installed apps with pip list or pip freeze, and trying to upgrade the pip version using pip install --upgrade pip also says the new version is successfully installed, but isn't installed within my virtual environment.
I've made sure to activate my virtual environment with source /home/travis/Documents/Python/Django/Projects/issuetracker/.env/bin/activate.
Output from pip install django-import-export:
(.env) [travis#spooky issuetracker]$ pip install django-import-export
Collecting django-import-export
Using cached https://files.pythonhosted.org/packages/62/7a/ddd9aef718243504e7715bda9bb5a100cfc353be37dc819d9914a7073cba/django_import_export-1.2.0-py2.py3-none-any.whl
Collecting tablib (from django-import-export)
Using cached https://files.pythonhosted.org/packages/7b/c7/cb74031b330cd94f3580926dc707d148b4ba9138449fc9f433cb79e640d8/tablib-0.13.0-py3-none-any.whl
Collecting diff-match-patch (from django-import-export)
Using cached https://files.pythonhosted.org/packages/f0/2a/5ba07def0e9107d935aba62cf632afbd0f7c723a98af47ccbcab753d2452/diff-match-patch-20181111.tar.gz
Requirement already satisfied: django>=1.8 in ./.env/lib/python3.7/site-packages (from django-import-export) (2.2.4)
Collecting openpyxl>=2.4.0 (from tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/f5/39/942a406621c1ff0de38d7e4782991b1bac046415bf54a66655c959ee66e8/openpyxl-2.6.3.tar.gz
Collecting xlwt (from tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/44/48/def306413b25c3d01753603b1a222a011b8621aed27cd7f89cbc27e6b0f4/xlwt-1.3.0-py2.py3-none-any.whl
Collecting xlrd (from tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/b0/16/63576a1a001752e34bf8ea62e367997530dc553b689356b9879339cf45a4/xlrd-1.2.0-py2.py3-none-any.whl
Collecting backports.csv (from tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/8e/26/a6bd68f13e0f38fbb643d6e497fc3462be83a0b6c4d43425c78bb51a7291/backports.csv-1.0.7-py2.py3-none-any.whl
Collecting odfpy (from tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/85/7d/8f6d1f2a4683be362b101c00232b4c3839e4e4a90e0945d8d43ec6aa671d/odfpy-1.4.0.tar.gz
Collecting pyyaml (from tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/e3/e8/b3212641ee2718d556df0f23f78de8303f068fe29cdaa7a91018849582fe/PyYAML-5.1.2.tar.gz
Requirement already satisfied: sqlparse in ./.env/lib/python3.7/site-packages (from django>=1.8->django-import-export) (0.3.0)
Requirement already satisfied: pytz in ./.env/lib/python3.7/site-packages (from django>=1.8->django-import-export) (2019.2)
Collecting jdcal (from openpyxl>=2.4.0->tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/f0/da/572cbc0bc582390480bbd7c4e93d14dc46079778ed915b505dc494b37c57/jdcal-1.4.1-py2.py3-none-any.whl
Collecting et_xmlfile (from openpyxl>=2.4.0->tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/22/28/a99c42aea746e18382ad9fb36f64c1c1f04216f41797f2f0fa567da11388/et_xmlfile-1.0.1.tar.gz
Collecting defusedxml (from odfpy->tablib->django-import-export)
Using cached https://files.pythonhosted.org/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Installing collected packages: jdcal, et-xmlfile, openpyxl, xlwt, xlrd, backports.csv, defusedxml, odfpy, pyyaml, tablib, diff-match-patch, django-import-export
Running setup.py install for et-xmlfile ... done
Running setup.py install for openpyxl ... done
Running setup.py install for odfpy ... done
Running setup.py install for pyyaml ... done
Running setup.py install for diff-match-patch ... done
Successfully installed backports.csv-1.0.7 defusedxml-0.6.0 diff-match-patch-20181111 django-import-export-1.2.0 et-xmlfile-1.0.1 jdcal-1.4.1 odfpy-1.4.0 openpyxl-2.6.3 pyyaml-5.1.2 tablib-0.13.0 xlrd-1.2.0 xlwt-1.3.0
WARNING: You are using pip version 19.2.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Python version:
(.env) [travis#spooky issuetracker]$ python -V
Python 3.7.4
Pip version:
(.env) [travis#spooky issuetracker]$ pip -V
pip 19.2.2 from /home/travis/Documents/Python/Django/Projects/issuetracker/.env/lib/python3.7/site-packages/pip (python 3.7)
.env/bin/pip:
#!/home/travis/Documents/Python/Django/Projects/issuetracker/.env/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
I'm not sure when this stopped working, since I was previously able to successfully install other packages into the same virtual environment. How can I ensure that pip is installing packages correctly into my virtual environment?
Update:
It seems that pip is installing into the .local/lib/python3.7/site-packages directory instead of .env/lib/python3.7/site-packages.
Found a fix/workaround in the answer to this question:
Pip installing packages to global site-packages when inside virtual environment
Like the OP of that question, I'm also running Manjaro Linux with the latest updates.

Error on installing packages on python

I tried to install pandas on my cmd and this is the output
Requirement already satisfied: pandas in c:\users\name\anaconda3\lib\site-packages (0.23.0)
Requirement already satisfied: python-dateutil>=2.5.0 in c:\users\name\anaconda3\lib\site-packages (from pandas) (2.7.3)
Requirement already satisfied: pytz>=2011k in c:\users\name\anaconda3\lib\site-packages (from pandas) (2018.4)
Requirement already satisfied: numpy>=1.9.0 in c:\users\name\anaconda3\lib\site-packages (from pandas) (1.14.3)
Requirement already satisfied: six>=1.5 in c:\users\name\anaconda3\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)
**distributed 1.21.8 requires msgpack, which is not installed.**
This last line is in red.
Im on windows 10, I installed anaconda
This seems to work for me.
First I tried
pip install msgpack
And if you need this too,
pip install msgpack-python
Then install whatever you need. In your case,
conda install pandas
You should install msgpack and then install pandas again.
How are you installing pandas? If you're using Anaconda, then
conda install pandas
is typically enough to make everything work. This is because Anaconda is using binary installs - it is uploading prebuilt code and has already done the combinatorics to make everything work together - and it gets everything it needs for a package.
Sometimes, of course, you have to go into a dependency combination that is tough, or you are pulling from non-core Anaconda repos, etc. In that case, you can try
conda install msgpack
# or
pip install msgpack
# or
conda install -c conda-forge msgpack
The right choice sort of depends on what you're doing. Using the -c flag with conda gives you access to non-core repositories - these carry fewer guarantees about working together, but gives you access to many more versions of the package, usually.
I am getting a similar error when trying to install pymc3. I solved it by using conda rather than pip.
The first time I used pip install pymc3 and I got the same error as you:
distributed 1.21.8 requires msgpack, which is not installed
Then I installed using conda instead: conda install pymc3, and it installed fine.
My understanding is that conda handles all the dependent packages for you, which pip does not.
I found this on the Anaconda site:
Use anaconda to install msgpack for python with this command:
conda install -c conda-forge msgpack-python
It seems to have worked for me.
conda install pip
pip uninstall -y msgpack-python
pip install msgpack
TCIP-scheduler
run these commands

Unable to update pip3 even though I try to update it

In summary, it seems I get into a loop where pip thinks I am using an outdated version of pip but when I try to upgrade it does NOT allow me. So I attempt an installation (from this question Jupyter Notebook can't find modules for python 3.6):
(automl) brandomiranda~ ❯ pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Requirement already up-to-date: ipykernel in /usr/local/lib/python3.6/site-packages (5.1.3)
Requirement not upgraded as not directly required: jupyter-client in /usr/local/lib/python3.6/site-packages (from ipykernel) (5.3.4)
Requirement not upgraded as not directly required: traitlets>=4.1.0 in /usr/local/lib/python3.6/site-packages (from ipykernel) (4.3.3)
Requirement not upgraded as not directly required: appnope; platform_system == "Darwin" in /usr/local/lib/python3.6/site-packages (from ipykernel) (0.1.0)
Requirement not upgraded as not directly required: tornado>=4.2 in /usr/local/lib/python3.6/site-packages (from ipykernel) (6.0.3)
Requirement not upgraded as not directly required: ipython>=5.0.0 in /usr/local/lib/python3.6/site-packages (from ipykernel) (7.11.1)
Requirement not upgraded as not directly required: jupyter-core>=4.6.0 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (4.6.1)
Requirement not upgraded as not directly required: pyzmq>=13 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (18.1.1)
Requirement not upgraded as not directly required: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (2.8.1)
Requirement not upgraded as not directly required: six in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (1.11.0)
Requirement not upgraded as not directly required: ipython-genutils in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (0.2.0)
Requirement not upgraded as not directly required: decorator in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (4.4.1)
Requirement not upgraded as not directly required: backcall in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.1.0)
Requirement not upgraded as not directly required: pickleshare in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.7.5)
Requirement not upgraded as not directly required: pexpect; sys_platform != "win32" in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (4.7.0)
Requirement not upgraded as not directly required: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (3.0.2)
Requirement not upgraded as not directly required: jedi>=0.10 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.15.2)
Requirement not upgraded as not directly required: pygments in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (2.5.2)
Requirement not upgraded as not directly required: setuptools>=18.5 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (39.0.1)
Requirement not upgraded as not directly required: ptyprocess>=0.5 in /usr/local/lib/python3.6/site-packages (from pexpect; sys_platform != "win32"->ipython>=5.0.0->ipykernel) (0.6.0)
Requirement not upgraded as not directly required: wcwidth in /usr/local/lib/python3.6/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=5.0.0->ipykernel) (0.1.8)
Requirement not upgraded as not directly required: parso>=0.5.2 in /usr/local/lib/python3.6/site-packages (from jedi>=0.10->ipython>=5.0.0->ipykernel) (0.5.2)
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Installed kernelspec python3 in /Users/brandomiranda/Library/Jupyter/kernels/python3
ok fine, I will upgrade but then it thinks its already upgraded:
(automl) brandomiranda~ ❯ pip install --upgrade pip
Requirement already up-to-date: pip in ./miniconda3/envs/automl/lib/python3.7/site-packages (19.3.1)
but when I try the installation again it fails with the same message. It seems like a chicken and egg problem. Anyone know what's going on?
Outdated:
I recently did a pip3 list to check what modules/projects I had installed in my virtual environment and I got a suggestion to upgrade pip. I tried but I can't seem to make it update/upgrade. I did:
$ pip3 list
namespaces (4.2.0)
pip (8.0.2)
scikit-learn (0.18.1)
setuptools (19.4)
six (1.10.0)
wheel (0.26.0)
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
so I tried doing that and it said it was working:
$ pip install --upgrade pip
Requirement already up-to-date: pip in /Users/user/home_simulation_research/hbf_tensorflow_code/venv/lib/python2.7/site-packages
since it said its alread there I did pip3 list again and it kept saying I didn't actually have it upgraded. Since updating with the standard pip command didn't work I instead tried using pip3 to do the update but it still didn't work:
pip3 install --upgrade pip3
Collecting pip3
Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Why doesn't it work?
Just when I thought it didn't work I tried using pip3 to upgrade pip and pip3 to upgrade pip3. For some reason the later doesn't seem to work but the first one does. i.e. doing:
$ pip3 install --upgrade pip
worked (or at least pip3 list) stopped requesting me upgrade. Why is that? Is it just me or is this really strange behaviour?
when you run pip3 list, you are listing packages installed for python3, and when you run pip install --upgrade pip, you are checking updates for python2 packages. when you run pip3 install --upgrade pip3, this would give an error because there is not package named pip3, pip3 is a command line tool provided in the pip package. When you finally run pip3 install --upgrade pip, you are doing the right thing(installing updates for python3, package name is pip).
What worked for me was to uninstall and install pip.
To uninstall pip do:
pip uninstall pip
although I went to the /usr/local/bin and deleted everything with pip name with:
rm -rf pip*
there were some pip3 things that were still there oddly enough.
Then I install pip with the (deprecated) sudo easy install:
sudo easy_install pip
although that command is deprecated, so something else has to be done in mac but for now that works (and made my jupyter notebook work again thus solving this question Jupyter Notebook can't find modules for python 3.6).
If you notice the difference in site-packages path you will get it.
When you are using pip3 /usr/local/lib/python3.6/site-packages path is shown which is python3.6.
Ref:
(automl) brandomiranda~ ❯ pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Requirement already up-to-date: ipykernel in /usr/local/lib/python3.6/site-packages (5.1.3)
And when you are using just pip you see it is python3.7 and totally different site-packages path ./miniconda3/envs/automl/lib/python3.7/site-packages
Ref:
(automl) brandomiranda~ ❯ pip install --upgrade pip
Requirement already up-to-date: pip in ./miniconda3/envs/automl/lib/python3.7/site-packages (19.3.1)
So both are different : pip3 points to direct system path(/usr/local/lib docs) which is Python3.6 and pip points to a virtual environment's path(./miniconda3/envs/automl/lib/) where python3.7 is installed.
You need to decide which one to upgrade and use. Having virtual environment is best practice.
The issue seems to be that new virtual environments are using an old version of pip. Note that pip is installed from a source tarfile (or wheel) included with virtualenv, in the site-packages/virtualenv_support directory.
$ ls -l /path/to/site-packages/virtualenv_support
pip-9.1-py2.py3-none-any.whl
A quick way to workaround the problem is to make sure you upgrade pip whenever you create a new virtualenv, like so:
$ virtualenv venv
$ venv/bin/pip install -U pip
Alternatively, make sure you have the latest version of virtualenv. According to their release notes, virtualenv==16 is using pip==10.
$ pip install -U virtualenv
Finally, since virtualenv looks for pip*.whl in virtualenv_support, this will also work:
$ mv /path/to/site-packages/virtualenv_support/pip*.whl{,bak}
$ pip wheel -w /path/to/site-packages/virtualenv_support/ 'pip==18'
All new virtualenvs will use the version of pip that you installed into virtualenv_support. However, this feels hacky.
(Attempted with virtualenv==16. This results in all new virtualenvs with pip==18.)
Stackoverflow Post - https://stackoverflow.com/questions/51644402/i-keep-getting-a-message-to-upgrade-pip
instead of pip install, I tend to run python3 -m pip install upgrade --user, to specify which python is intended
To get me out of a similar loop of hell, I simply re-installed pip with the following command :
curl https://bootstrap.pypa.io/get-pip.py | python3.7
Just specify the right python version you want pip to be installed with.
Url is from https://pip.pypa.io/en/stable/installing/

Categories

Resources