Why isn't pip v7.1.0 caching wheels? - python-3.x

I'm running pip v7.1.0 (latest as of this writing) and running into an issue where it's not caching at all.
Here is how I'm installing Django -
pip install --cache-dir=d:\pipcache django
The package installs successfully, but there is nothing cached. I've read the latest documentation and checked my AppData/Local path and it's empty. What I'm looking to do is have everything I install through pip cached, so all subsequent virtual environment creations are quick.
EDIT
Turns out that pip won't cache packages that have wheel files. I tried forcing pip to build the source --no-binary=django to no avail.
Having said that, how can I force pip to cache my requirements whether the maintainers have provided wheels or not?
Based on my understanding of pip, this should be the new default. Not sure why it isn't working, though.
Alternatively, I have to do this -
pip wheel --wheel-dir="D:/"-r reqs
pip install --no-index --find-links="D:/" -r reqs

Is this within a venv? If so, you may have to explicitly install wheel into the venv using pip install wheel. After that, pip should start automatically building/caching your wheels.

Related

Pip: force installation of package version from a git repo

I am facing the problem to install a package based on a specific commit hash from Github.
This works great if the used venv does not already contain the installed package:
pip install --upgrade git+https://github.com/user/pyckagexyz.git#1234567890032ab36c732dc32d9c257d401e71b0
This installs pyckagexyz and it's dependencies if it does not yet exist in the used venv. If it already exists this command does nothing. I also tried without success
pip install --upgrade --no-cache-dir git+https://github.com/user/pyckagexyz.git#1234567890032ab36c732dc32d9c257d401e71b0
=> No effect
pip install --upgrade --force git+https://github.com/user/pyckagexyz.git#1234567890032ab36c732dc32d9c257d401e71b0
=> Installation fails because on of the dependencies can't be installed.
The only workaround I have found so far is to uninstall the package before re-installing it or to first install the package without dependencies and force --no-deps --force and then again a second time without force and dependencies to make sure all dependencies are present.
Is there no other way to say pip to install the selected version of a packet and overwrite an installed version?
Have you tried the --force-reinstall option with pip install?
pip install --force-reinstall git+https://github.com/user/pyckagexyz.git#1234567890032ab36c732dc32d9c257d401e71b0
From the pip docs:
--force-reinstall
Reinstall all packages even if they are already up-to-date.

does pip reinstall libraries everytime when creating a virtual environment?

I know it might sound stupid, but I genuinely tried my best to understand if pip installs packages from the internet every single time or does it just clone and use the already globally installed packages when I am creating a venv?
What exactly is the difference between pip install and pip download?
What does it mean by
Collecting package <package_name>...
Using cached <package_name>...
and
Downloading <package_name>
Can someone help me out...
pip download replaces the --download option to pip install, which is now deprecated and was removed in pip 10.
pip download does the same resolution and downloading as pip install, but instead of installing the dependencies, it collects the downloaded distributions into the directory provided (defaulting to the current directory). This directory can later be passed as the value to pip install --find-links to facilitate offline or locked down package installation.
The idea behind the pip cache is simple, when you install a Python package using pip for the first time, it gets saved on the cache. If you try to download/install the same version of the package on a second time, pip will just use the local cached copy instead of retrieving it from the remote register .
If you plan to use the same version of the package in another project then using cached packages is much faster.
But if pip installs the cached version of the package and you want to upgrade to the newest version of the package then you can simply upgrade by: pip install <package_name> --upgrade

PIP UPGRADE - Trouble with versions in personal setup package

I'm working on my first python package, so I'm new with all this.
I have my own setup package which I install through pip install git+<URL>.git.
When I try to upgrade it with the --upgrade flag, it always get reinstalled, even if I haven't changed the version in my setup.py file.
Does anyone know why this is happening? o maybe have a better approach to this?
I have made my research before asking, but I think this is a very specific problem.
I have tried in a venv and out.
python 3.7, pip 19.2, setuptools 40.8
# setup.py
from test import __version__
from setuptools import find_packages, setup
setup(
name="test",
version=__version__,
packages=find_packages(),
)
I expect to get something similar to:
Requirement already up-to-date: test in ./<cwd>/.venv/lib/python3.7/site-packages (0.0.1)
but instead I get this:
Installing collected packages: test
Found existing installation: test 0.0.1
Uninstalling test-0.0.1:
Successfully uninstalled test-0.0.1
Running setup.py install for test ... done
Successfully installed test-0.0.1
Reading the documentation it seems like the expected behaviour to me.
Note that if a satisfactory version of the package is already installed, the VCS source will not overwrite it without an --upgrade flag.
Read a somewhat related discussion here:
https://github.com/pypa/pip/issues/2837
Looks like pip does upgrades in a much more binary fashion when VCS is involved. It seems to always upgrade when --upgrade is set and never when it's not set.
You could try the work-around that is suggested in this discussion, but be aware of its side effects (for example, you will have a full clone of the git repository on your file system):
pip install --editable --upgrade git://somewhere/something.git

How to install library

I am a little bit confused....
I installed anaconda on my computer (I have windows 10).
Normally, when I want to install a package I simply do "pip install package_name" or "conda install package_name" and it is done.
First question: what is the difference between pip and conda?
Now I tried to install xgboost and it was really complicated I tried lot of things nothings worked until I install something called miniconda.
There it works but now, when I do "conda install package_name" it install it in miniconda3/lib/site _package and I have to copy/paste it in Anaconda3/lib/site_package if I want it to work.
Second question: how can I ask to the computer that "conda install
package_name" install it directly in anaconda3 and not miniconda3?
Finally I tried to install the package "surprise" for recommended systems. Both "pip install" or "conda install" failed.
I went in github and got the file "surprise" from https://github.com/NicolasHug/Surprise
I tried to copy it in Anaconda3/lib/site_package but it doesn't work.
When I do from surprise import Reader I did not get the error "no module name surprise" anymore but I get "cannot import name 'Reader'"
Last question: how can I make it work? I think I have to build it but
I do not now how...
Thank you in advance for anyone that can explain all this for me :-)
Similarly to you, I had issues installing the surprise package.
I tried both pip install surprise and conda install surprise unsuccessfully.
conda install -c conda-forge scikit-surprise
conda install -c conda-forge/label/gcc7 scikit-surprise
conda install -c conda-forge/label/cf201901 scikit-surprise
I found those on the anconda website and the first one worked for me.
Hopefully this would help you as well
pip vs conda
pip is a package manager that facilitates installation, upgrade,
and uninstallation of python packages. It also works with virtual python environments.
conda is a package manager for any software (installation, upgrade and uninstallation).
It also works with virtual system environments.
Conda is a packaging tool and installr that aims to do more than what pip does;
handle library dependencies outside of the Python packages as well as the Python packages themselves.
Conda also creates a virtual environment, like virtualenv does.
For more see here
Anaconda vs miniconda
The open source version of Anaconda is an easy-to-install
high performance Python and R distribution with a package manager,
environment manager and collection of 720+ open source packages.
It also comes with the options to install RStudio.
The "lite" version of Anaconda without the collection of 720 packages.
The downside is that you need to type in command line commands,
"conda install PACKAGENAME"
And Last
To install this package with conda run:
conda install -c anaconda py-xgboost=0.60
Update for surprise
The easiest way is to use pip (you'll need numpy):
$ pip install numpy
$ pip install scikit-surprise
Or you can clone the repo and build the source (you'll need Cython and numpy):
$ git clone https://github.com/NicolasHug/surprise.git
$ python setup.py install

Error installing urllib3

I am using the command pip install urllib3, the error trace I am getting is as below.
Which pip version do you use?
Try first to run the command pip install --upgrade pip
After that, when your pip version is up-to-date try to install the urllib3.
EDIT:
Alternatively, you can grab the latest source code from GitHub:
git clone git://github.com/shazow/urllib3.git
python setup.py install
Without seeing the full traceback, this looks like your computer cannot resolve the addresses for pypi.python.org or pypi.org (I dont' know what version of pip you're using).
This could be because of a proxy issue or some other internet connectivity issue. There is literally no way for someone to help you debug this without more information.
Finally
pip install urllib3 version=2.4.0
Does not do what you think. What you told pip to do was install urllib3 and install a package named version. If you want a specific version you need to write
pip install urllib3===1.4.0
Or whatever version you need.

Resources