Why can I install pytorch with pip but not with pipenv - python

I am a relative pipenv newbie, and I am trying to install pytorch with cuda 11 for a machine learning project.
I am installing pytorch on linux with python 3.6. I have made a fresh pipenv environment with pipenv install.
To install the latest version of pytorch with cuda 11, the command is:
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
When I run this command, it works fine and installs:
$ pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.7.0+cu110
Using cached https://download.pytorch.org/whl/cu110/torch-1.7.0%2Bcu110-cp36-cp36m-linux_x86_64.whl (1137.1 MB)
Collecting torchvision==0.8.1+cu110
Using cached https://download.pytorch.org/whl/cu110/torchvision-0.8.1%2Bcu110-cp36-cp36m-linux_x86_64.whl (12.9 MB)
Collecting torchaudio===0.7.0
Using cached torchaudio-0.7.0-cp36-cp36m-manylinux1_x86_64.whl (7.6 MB)
Collecting dataclasses
Using cached dataclasses-0.8-py3-none-any.whl (19 kB)
Collecting numpy
Using cached numpy-1.19.4-cp36-cp36m-manylinux2010_x86_64.whl (14.5 MB)
Processing /home/denisonc/.cache/pip/wheels/6e/9c/ed/4499c9865ac1002697793e0ae05ba6be33553d098f3347fb94/future-0.18.2-py3-none-any.whl
Collecting typing-extensions
Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting pillow>=4.1.1
Using cached Pillow-8.0.1-cp36-cp36m-manylinux1_x86_64.whl (2.2 MB)
Installing collected packages: dataclasses, numpy, future, typing-extensions, torch, pillow, torchvision, torchaudio
Successfully installed dataclasses-0.8 future-0.18.2 numpy-1.19.4 pillow-8.0.1 torch-1.7.0+cu110 torchaudio-0.7.0 torchvision-0.8.1+cu110 typing-extensions-3.7.4.3
(deep-sinter) [denisonc#cvgpu02 deep-sinter]$ pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (ca72e7)!
Installing dependencies from Pipfile.lock (ca72e7)...
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
All dependencies are now up-to-date!
However, changing 'pip' to 'pipenv' causes the following error:
$ pipenv install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Installing torch==1.7.0+cu110...
Error: An error occurred while installing torch==1.7.0+cu110!
Error text:
ERROR: Could not find a version that satisfies the requirement torch==1.7.0+cu110 (from -r /tmp/pipenv-tvts06b7-requirements/pipenv-0wd75ill-requirement.txt (line 1)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0)
ERROR: No matching distribution found for torch==1.7.0+cu110 (from -r /tmp/pipenv-tvts06b7-requirements/pipenv-0wd75ill-requirement.txt (line 1))
✘ Installation Failed
Last week I was able to complete this installation on the same system in a different pipenv. In the mean time I upgraded pipenv to the latest version. This error occurred after the upgade.
This is very confusing to me because my understanding was that pipenv uses pip under the hood. I can't understand why the behavior would be different. I would like to install pytorch within my pip environment so that I can keep libraries isolated from other projects.

Related

how do i revert an pip upgrade

I did the following command just now,
pip install --upgrade ipykernel
However, i got
Requirement already satisfied: ipykernel in ./anaconda3/lib/python3.8/site-packages (5.3.4)
Collecting ipykernel
Downloading ipykernel-6.5.0-py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 4.3 MB/s
Collecting ipython<8.0,>=7.23.1
Downloading ipython-7.29.0-py3-none-any.whl (790 kB)
|████████████████████████████████| 790 kB 9.2 MB/s
Collecting debugpy<2.0,>=1.0.0
Downloading debugpy-1.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.9 MB)
|████████████████████████████████| 1.9 MB 126.8 MB/s
Collecting matplotlib-inline<0.2.0,>=0.1.0
Downloading matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)
Collecting traitlets<6.0,>=5.1.0
Downloading traitlets-5.1.1-py3-none-any.whl (102 kB)
|████████████████████████████████| 102 kB 20.5 MB/s
...
Requirement already satisfied: python-dateutil>=2.1 in ./anaconda3/lib/python3.8/site-packages (from jupyter-client<8.0->ipykernel) (2.8.1)
Requirement already satisfied: ptyprocess>=0.5 in ./anaconda3/lib/python3.8/site-packages (from pexpect>4.3->ipython<8.0,>=7.23.1->ipykernel) (0.7.0)
Requirement already satisfied: wcwidth in ./anaconda3/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython<8.0,>=7.23.1->ipykernel) (0.2.5)
Requirement already satisfied: six>=1.5 in ./anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.1->jupyter-client<8.0->ipykernel) (1.15.0)
Installing collected packages: traitlets, matplotlib-inline, ipython, debugpy, ipykernel
Attempting uninstall: traitlets
Found existing installation: traitlets 5.0.5
Uninstalling traitlets-5.0.5:
Successfully uninstalled traitlets-5.0.5
Attempting uninstall: ipython
Found existing installation: ipython 7.22.0
Uninstalling ipython-7.22.0:
Successfully uninstalled ipython-7.22.0
Attempting uninstall: ipykernel
Found existing installation: ipykernel 5.3.4
Uninstalling ipykernel-5.3.4:
Successfully uninstalled ipykernel-5.3.4
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spyder 4.2.5 requires pyqt5<5.13, which is not installed.
spyder 4.2.5 requires pyqtwebengine<5.13, which is not installed.
conda-repo-cli 1.0.4 requires pathlib, which is not installed.
Successfully installed debugpy-1.5.1 ipykernel-6.5.0 ipython-7.29.0 matplotlib-inline-0.1.3 traitlets-5.1.1
I would like to revert my command, since some of my codes suddenly does not work
. Is it possible? Thanks!
It seems a lot fo packages are installed.
Update
So I actually had my environment.yaml from my previous conda env export > environment.yaml
If I do
conda env update --file environment.yaml --prune
It does not help me revert to my previous versions.... Can I force my base environment back to exactly environment.yaml?
I do not believe pip keeps a history of installed packages. If you have the text output from the terminal when you did the upgrade, pip does output a list of packages that will be installed, which version you had and which version you're replacing it with. You can manually revert each package by doing
pip uninstall <package_name> && pip install <package_name>==<version_number>
Edit: Based on your edits, I suggest you repost this question in terms of your conda environment. That's a totally different system, even though it does utilize pip.
As a side note, you might be able to get away with just running
pip install traitlets==5.0.5
pip install ipykernel==5.3.4
pip install ipython==7.22.0

Python build always reinstall setuptools

I am using Python 3.8 in conda, and using build to create packages. Although in my Conda env I already have setuptools 51.0 and wheel 0.36, everytime I run python -m build --wheel I see the following messages:
Found existing installation: setuptools 49.2.1
Uninstalling setuptools-49.2.1:
Successfully uninstalled setuptools-49.2.1
Collecting wheel
Using cached wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Collecting setuptools>=51
Using cached setuptools-58.3.0-py3-none-any.whl (946 kB)
Installing collected packages: wheel, setuptools
Successfully installed setuptools-58.3.0 wheel-0.37.0
Here the existing packages don't even match what I have in Conda, and I don't think I need the newest packages either. Could anyone explain why this is happening?
refer to this topic https://pypa-build.readthedocs.io/en/latest/#python--m-build-optional-arguments
By default build will build the package in an isolated environment, but this behavior can be disabled with --no-isolation.
so you may need to add --no-isolation flag to force using your project's virtual environment like so:
python -m build --wheel --no-isolation

Having trouble installing PyTorch

I'm having trouble installing PyTorch.
C:\Users\myself>pip install torch
Collecting torch
Using cached torch-1.7.1-cp38-cp38-win_amd64.whl (184.0 MB)
Requirement already satisfied: numpy in c:\users\myself\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from torch) (1.19.1)
Requirement already satisfied: typing-extensions in c:\users\myself\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from torch) (3.7.4.3)
Installing collected packages: torch
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\myself\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\caffe2\\python\\serialized_test\\data\\operator_test\\learning_rate_adaption_op_test.test_learning_rate_adaption_op_normalization.zip'
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\myself\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
It says that I'm missing a file in caffe2, but I'm not sure how I can get that file back.
Torch wheel contains caffe2 directory.
1.Try --no-cache-dir option
pip install --no-cache-dir torch
2. Removing the MAX_PATH Limitation
See here 3. Using Python on Windows — Python 3.7.9 documentation. You can find some more detailed discussion here.

unable to install pdflatex using spyder

pip install attrs==19.2.0 --user Collecting attrs==19.2.0 Using cached attrs-19.2.0-py2.py3-none-any.whl (40 kB) Installing collected
packages: attrs Attempting uninstall: attrs
Found existing installation: attrs 19.1.0
Uninstalling attrs-19.1.0:
Successfully uninstalled attrs-19.1.0 Successfully installed attrs-19.2.0 Note: you may need to restart the kernel to use updated
packages. ERROR: pdflatex 0.1.3 has requirement attrs<19.0,>=18.2, but
you'll have attrs 19.2.0 which is incompatible.
pip install pdflatex --user Requirement already satisfied: pdflatex in
c:\users\haris\appdata\roaming\python\python37\site-packages (0.1.3)
Collecting attrs<19.0,>=18.2 Using cached
attrs-18.2.0-py2.py3-none-any.whl (34 kB) Installing collected
packages: attrs Attempting uninstall: attrs
Found existing installation: attrs 19.2.0
Uninstalling attrs-19.2.0:
Successfully uninstalled attrs-19.2.0 Successfully installed attrs-18.2.0 Note: you may need to restart the kernel to use updated
packages. ERROR: hypothesis 5.5.4 has requirement attrs>=19.2.0, but
you'll have attrs 18.2.0 which is incompatible.
need help to install pdflatex

ERROR: Could not find a version that satisfies the requirement tensorflow==2.1.0 and No matching distribution found for tensorflow==2.1.0

I am trying to use 'pipenv' on Windows Subsystem for Linux (ubuntu 18.04)
When I run
$ pipenv sync
I am getting this error :
[pipenv.exceptions.InstallError]: ['ERROR: Could not find a version that satisfies the requirement
tensorflow==2.1.0 (from -r /tmp/pipenv-gy0uz1a7-requirements/pipenv-glre38t7-requirement.txt (line 1))
(from versions: 2.2.0rc1, 2.2.0rc2)', 'ERROR: No matching distribution found for tensorflow==2.1.0
(from -r /tmp/pipenv-gy0uz1a7-requirements/pipenv-glre38t7-requirement.txt (line 1))']
I followed some other instructions that say I have to install tensorflow, so I installed tensorflow
$ pip install --upgrade pip
$ pip install tensorflow==2.1.0
Even after installing tensorflow 2.1.0 I am still getting the same error when I run
$ pipenv sync
What should I do to fix this problem?
Check your python version, the python 3.8 doesn't support TensorFlow 2.1 version.

Categories