Error on installing packages on python - 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

Related

How to prevent pip from installing a package if it has been installed by conda already

I'm experimenting with my python package. I use anaconda and, inside my environment, I have packages that I need already installed:
conda list | egrep "rdkit|numpy"
returns
numpy 1.19.2 py39h89c1606_0
numpy-base 1.19.2 py39h2ae0177_0
rdkit 2022.03.1b1.0 py39he30056e_1 rdkit/label/beta
My setup.py has two dependencies without specifying versions:
install_requires=[
'rdkit',
'numpy',
],
But when I run pip install . it installs another version of rdkit
Collecting rdkit
Using cached rdkit-2022.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.9 MB)
The question is, how to prevent pip from such behavior? I want something like: if a package has already been installed, whatever the version, just keep it and do nothing.
You could try:
pip install --no-cache-dir
to avoid cached versions.
Check this link, it might have what you need:
pip uses incorrect cached package version, instead of the user-specified version

Installing a package with both conda and pip

If I've installed a python package using both conda and pip then when I call a function from that package, will I be using the version from conda or from pip?
My situation is as follows: I'm trying to use the from_estimator method released in scikit-learn version 1.0. this past September. However, my current version of scikit-learn was version 0.24.2 so I decided to update the package. I previously had installed conda, but never actually used it to update/install a package; instead I always used pip. This time I decided to try to install scikit-learn version 1.0 with conda. However, when I wrote conda install scikit-learn=1.0 in terminal, I got the error
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- scikit-learn=1.0
Frustrated, I decided to simply install scikit-learn version 1.0 with pip by typing pip install -U scikit-learn in terminal. This gave me the message
Requirement already satisfied: scikit-learn in /home/eturok/anaconda3/lib/python3.7/site-packages (0.24.2)
Collecting scikit-learn
Downloading scikit_learn-1.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (23.1 MB)
|████████████████████████████████| 23.1 MB 17.2 MB/s
Requirement already satisfied: joblib>=0.11 in /home/eturok/anaconda3/lib/python3.7/site-packages (from scikit-learn) (1.0.1)
Requirement already satisfied: scipy>=1.1.0 in /home/eturok/anaconda3/lib/python3.7/site-packages (from scikit-learn) (1.7.1)
Requirement already satisfied: numpy>=1.14.6 in /home/eturok/anaconda3/lib/python3.7/site-packages (from scikit-learn) (1.20.3)
Requirement already satisfied: threadpoolctl>=2.0.0 in /home/eturok/anaconda3/lib/python3.7/site-packages (from scikit-learn) (2.2.0)
Installing collected packages: scikit-learn
Attempting uninstall: scikit-learn
Found existing installation: scikit-learn 0.24.2
Uninstalling scikit-learn-0.24.2:
Successfully uninstalled scikit-learn-0.24.2
Successfully installed scikit-learn-1.0
Now typing pip list and conda list in terminal returns scikit-learn 1.0 and scikit-learn 1.0 pypi_0 pypi respectively.
My questions are:
If I only updated scikit-learn with pip, why is scikit-learn also updated with conda?
Why at the beginning was I unable to update scikit-learn with conda? This version of scikit-learn was released pretty recently. Is it possible that conda hasn't yet gotten around to supporting the new release of scikit-learn yet?
In general, how does conda decide which packages to support?
If I've installed a python package using both conda and pip then when I call a function from that package, will I be using the version from conda or from pip?
Not a conda expert, but since no one is bothering to answer:
I don't think it was. You got an error and installation was aborted. Might it be that conda list just sees the pip installed package and reports it as comming from pypi?
Yes, conda default repo for scikit-learn does not have 1.0 yet, 0.24 is the last (see here: https://anaconda.org/anaconda/scikit-learn). The conda-forge repo for scikit learn does have 1.0 (see here: https://anaconda.org/conda-forge/scikit-learn)
I don't know how packages move from conda-forge to conda. Probably you should always use conda forge as in conda install -c conda-forge scikit-learn. Or, even better, always use pip.
No idea, don't do it :) Always use either conda or venv virtual environments and in such cases burn them with fire and start anew.

pip installing in usr/lib/python3.6/site-packages instead of virtualenv on ubuntu server

I'm having a problem when installing packages on my virtualenv.It all started when I upgraded my pip to the latest version. I tried to revert my pip version to where I find it stable. When I try to install, for example, django-tables2, it says:
Requirement already satisfied: django-tables2 in /usr/lib/python3.6/site-packages (2.3.1)
Requirement already satisfied: Django>=1.11 in /usr/local/lib/python3.6/dist-packages (from django-tables2) (2.2.4)
Requirement already satisfied: pytz in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-tables2) (2019.2)
Requirement already satisfied: sqlparse in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-tables2) (0.3.0)
WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But when I check my folder in my virtualenv, it doesn't show there. I tried some commands like which pip and which pip3 and it says this:
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject# which pip
/home/unidaweb/unidaproject/unidaenv/bin/pip
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject# which pip3
/home/unidaweb/unidaproject/unidaenv/bin/pip3
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject#
I also tried pip list but I can't find the package that I installed to my virtualenv.
I'm getting a bad gateway error when I try to add it on my settings.py, I don't really know how to fix this but when I'm in the version of pip that I know was stable running my project, I don't get this error and I can install any package that I needed to my project. Any help would be much appreciated. I'm stuck on this for about a week, hoping that someone could help me with this issue.
virtualenvs can break occasionally especially if the somebody updated the python executable the virtualenv was based or some packages / shared libraries of it.
I'd suggest to try out with a new virtualenv. (delete the broken one and replace it)
Further.
for debugging I suggest to type following two commands:
type -a python and type -a pip
In case your search path has some hidden surprises it could be safer to call
python -m pip instead of python though in a properly setup virtualenv it shouldn't make a difference.

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

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!

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