Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pipenv option to mimic pip -f option

In pip there is an -f option which does the following:

-f, --find-links : If a url or path to an html file, then parse for links to archives. If a local path or file:// url that's a directory, then look for archives in the directory listing.

This is the preferred way of installing PyTorch, by setting the link to their overview website, e.g.:

pip3 install torch===1.3.0 -f https://download.pytorch.org/whl/torch_stable.html

For my virtual environments I use pipenv but I haven't found an option that does the same as -f. In the meantime, I can just look up the direct link to the package that is relevant for my system, but that is cumbersome.

Does pipenv provide a way to do the same thing as pip's -f?

like image 831
Bram Vanroy Avatar asked Aug 25 '19 16:08

Bram Vanroy


People also ask

Can I use pip with Pipenv?

Yes, because as I said, they both just use pip . Both methods will install the packages in the same virtual environment and pipenv graph is just checking that same env. The packages will be stored in a folder under lib/pythonX.

Is Pipenv better than pip?

While pip can install Python packages, Pipenv is recommended as it's a higher-level tool that simplifies dependency management for common use cases. This does a user installation to prevent breaking any system-wide packages.

What is pip Pipenv?

Pipenv is a tool that provides all necessary means to create a virtual environment for your Python project. It automatically manages project packages through the Pipfile file as you install or uninstall packages.

Does Pipenv install use Pipfile or Pipfile lock?

Use a Pipenv projectPipenv will read the Pipfile and Pipfile. lock files for the project, create the virtual environment, and install all of the dependencies as needed.


2 Answers

It is possible to use environment variables recognised by pip to tweak its behaviour within pipenv's execution. E.g.:

PIP_FIND_LINKS=https://download.pytorch.org/whl/torch_stable.html pipenv install torch==1.5.1+cu101

See:

  • Advanced Usage of Pipenv - Configuration With Environment Variables
  • pip's User Guide - Environment Variables
like image 167
Dmitry Kashtanov Avatar answered Oct 09 '22 22:10

Dmitry Kashtanov


In the new version of pipenv (I tested with version 2020.11.15), you can install packages in this way:

pipenv install https://download.pytorch.org/whl/cpu/torch-1.3.0%2Bcpu-cp36-cp36m-linux_x86_64.whl

The link can be found in the this page: https://download.pytorch.org/whl/torch_stable.html

This will be added to the Pipfile as well.

[packages]
torch = {file = "https://download.pytorch.org/whl/cpu/torch-1.3.0%2Bcpu-cp36-cp36m-linux_x86_64.whl"}

you need to manually check the link with your compute platform, os and python version.

like image 35
Wsine Avatar answered Oct 09 '22 22:10

Wsine