haochengxia / vscode-pydata-viewer

Display PyData files (.npz .npy .pkl .pth) in VSCode.
https://marketplace.visualstudio.com/items?itemName=Percy.vscode-pydata-viewer
MIT License
17 stars 10 forks source link

No module named 'torch' #5

Closed Fizinftop99 closed 1 year ago

Fizinftop99 commented 1 year ago

No module named 'torch' in .pth file after PATH = './cifar_net.pth' torch.save(net.state_dict(), PATH)

haochengxia commented 1 year ago

Thank you for bringing up this issue. The error you encountered may have been caused by the data object being a built-in type in the torch library, while the default Python interpreter does not have the torch package installed. To resolve this issue, please modify the vscode-pydata-viewer.pythonPath extension setting to point to an interpreter that has the torch package installed.

Aldlevine commented 1 year ago

I had a similar issue with torch installed in .venv, but not globally. I fixed it by changing the python-path setting to the .venv version of python (appears to need absolute path).