Rukan Mahfuz
Rukan Mahfuz

Reputation: 87

ImportError: cannot import name 'Optional' from 'torch.jit.annotations'

I have installed cpuonly pytorch and torchvision in anaconda. But when i try to import torchvision i get the following error.

ImportError: cannot import name 'Optional' from 'torch.jit.annotations'(C:\Users\MSI\Anaconda3\lib\site-packages\torch\jit\annotations.py)

How can i fix this?

Upvotes: 1

Views: 5269

Answers (1)

Donald S
Donald S

Reputation: 1753

Not sure if you are installing the correct versions of the libraries. This combination seems to work:

conda create --name test5 python=3.6
conda install -c pytorch pytorch torchvision cpuonly
python
>>> import torchvision

Upvotes: 1

Related Questions