Import torch not working

Hi, I’m an artist, not a programmer, and I’m trying to install pytorch to install a neural network style transfer software, following this guide , but when I reach the step right after pytorch is installed (with it saying everything installed properly) when I try to run the next command which is
python models/ it just gives me an error and says that the torch module can not be imported because it does not exist

I have python 3.8.6 installed and I used the anaconda command without Cuda for installing pytorch

CC @ProGamerGov as the repo author :slight_smile:

@MarcAndrew_Laurenvil I myself don’t have Anaconda setup (I use pip and Python installed normally), but it sounds like you are having an issue with installing PyTorch and making it work with Anaconda as there’s no neural-style-pt specific errors. The line import torch is a default PyTorch import. @ptrblck May be able to point you in a better direction for Anaconda/PyTorch support.

I did a quick search, and found these links that might be useful for helping resolve the issue. They vary from Anaconda environment issues to incompatible Python versions:

Thank you so much for replying! I’ve been trying to set up neural style for months using the GUI version here But I’m on Windows so this only works with your pytorch version of neural style, I tried every possible windows based method of installation and I still can’t get it to work, when I try running to install pip for example, it goes through the installation successfully, and I even added the python scripts folder to my windows path, but when I then turn around and type pip-V it says pip is not recognized as a command, Is there a different way to install pip, or something that I’m missing, I don’t think theres anyway I would be able to figure out the Anaconda method of installation on my own


For my own Windows computer, I installed Python from the official site (remember to click the option to add Python to your windows path or whatever it’s called when installing):

I’m not sure if all the versions of Python available work with PyTorch, but @ptrblck may know.

After installing Python, I get the PyTorch install command by selecting pip instead of Conda, Windows, Python, and Cuda 10.2 from the official site here:

I then download repositories like neural-style-pt as a zip, unzip and open the folder, then I copy the file path to cmd after the cd command. Since you’re new to this sort of thing, always try to make sure that commands have the proper spacing as well.

I’ve never run into any issues installing PyTorch and using it this way. Hopefully it’ll work for you as well!

If you run into an issue with the GUI program, you’ll have to ask cameronleger here: as he’s the one who made it.

The support for Python3.5 was recently removed, if I’m not mistaken, so 3.6 should be the minimal version (3.7 and 3.8 are supported as well).