Vision: Unable to import after installing via Pipenv

Created on 25 Mar 2020  路  7Comments  路  Source: pytorch/vision

馃悰 Bug

I have installed torch and torchvision via Pipenv using wheels provided on the website. Here's Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"

[packages]
numpy = "*"
pillow = "*"
torch-win = {file = "https://download.pytorch.org/whl/cu101/torch-1.4.0-cp37-cp37m-win_amd64.whl#egg=torch-win", sys_platform = "== 'win32'"}
torchvision-win = {file = "https://download.pytorch.org/whl/cu101/torchvision-0.5.0-cp37-cp37m-win_amd64.whl#egg=torchvision-win", sys_platform = "== 'win32'"}

[requires]
python_version = "3.7"

When I try to import torchvision, I get an error: ModuleNotFoundError: No module named six. It successfully imports the module after adding six = "*" in the Pipfile and installing everything again.

To Reproduce

Steps to reproduce the behavior:

  1. Install Pipenv, add the Pipfile from above and run pipenv install
  2. Run Python shell and try import torchvision

Stack trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\<USER>\Desktop\<PROJECT>\.venv\lib\site-packages\torchvision\__init__.py", line 4, in <module>
    from torchvision import datasets
  File "C:\Users\<USER>\Desktop\<PROJECT>\.venv\lib\site-packages\torchvision\datasets\__init__.py", line 1, in <module>
    from .lsun import LSUN, LSUNClass
  File "C:\Users\<USER>\Desktop\<PROJECT>\.venv\lib\site-packages\torchvision\datasets\lsun.py", line 5, in <module>
    import six
ModuleNotFoundError: No module named 'six'

Expected behavior

Successful import of torchvision.

Environment

PyTorch version: 1.4.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Microsoft Windows 10 Enterprise
GCC version: Could not collect
CMake version: Could not collect

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: 10.1.105
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.18.2
[pip3] torch==1.4.0
[pip3] torchvision==0.5.0
[conda] Could not collect
  • PyTorch / torchvision Version (e.g., 1.0 / 0.4.0): 1.4.0 / 0.5.0
  • OS (e.g., Linux): Windows
  • How you installed PyTorch / torchvision (conda, pip, source): Pipenv from wheel (see Pipfile
  • Python version: 3.7.5
  • CUDA/cuDNN version: 10.1
  • GPU models and configuration: GeForce RTX 2080 Ti
bug help wanted binaries windows

Most helpful comment

Sorry, I've never tried this before. But I agree with @fmassa that we could remove the dependency six since only python 3 packages are available for Windows.

All 7 comments

Thanks for the bugreport!

This seems to be an issue in Windows. @peterjc123 could you have a look? Maybe now that we are Python3-only we should remove all instances of six in the codebase for simplicity?

EDIT: created an issue to remove six dependency in https://github.com/pytorch/vision/issues/2015

Sorry, I've never tried this before. But I agree with @fmassa that we could remove the dependency six since only python 3 packages are available for Windows.

@peterjc123 I think a quick fix for now is just to add six as a dependency for the windows packages? IIRC we have those as dependency for the Linux / OSX

Okay, no problem.

@fmassa Looks like six is already added as a requirement during pip install. https://github.com/pytorch/vision/blame/master/setup.py#L72

Yeah, that's true.

I don't know precisely why this is happening with Pipenv, I think it should work.
Anyway, we will be soon removing six as a dependency, and the fix for now is just to install six as well, so I'd say this will be transitively fixed soon

Fixed via #2015.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martinarjovsky picture martinarjovsky  路  4Comments

xuanqing94 picture xuanqing94  路  3Comments

yxlabs picture yxlabs  路  4Comments

IssamLaradji picture IssamLaradji  路  3Comments

zhang-zhenyu picture zhang-zhenyu  路  3Comments