-1

I have a strange issue that I have a folder causes errors in my python code. If I run python and import torch from the terminal then I get this error

AttributeError: module 'torch' has no attribute 'Tensor'

If I open python in the terminal and import torch from any other folder then there is no error. I did get this file directly from a drive that I was using for a backup. Could this be causing the issue. I know before it was a read only folder, but I fixed that.

The folder I am trying to use is located in the Desktop. I can run everything completely fine in the Desktop folder, but as soon as I enter this one, I get the error. I have looked at pytorch, AttributeError: module 'torch' has no attribute 'Tensor' but dont think it is the same error. Since I also get an error with other packages such as ctypes which gives me this error.

AttributeError: module 'ctypes' has no attribute 'WinDLL'

This error has the same property as the previous one, that it only happens when the terminal is running python from this folder. It is able to import ctypes completely fine outside of this folder.

Folder:

->check.py

->createVoice.py

->final.wav

->hi.py

->struct.py

->test.wav

->welcome.wav

  • [pytorch, AttributeError: module 'torch' has no attribute 'Tensor'](https://stackoverflow.com/questions/47317141/pytorch-attributeerror-module-torch-has-no-attribute-tensor) ? – Anurag Dabas Jun 05 '21 at 01:54
  • @AnuragDabas I already looked at this, I dont think it is the same issue becuase this happens only in a specefic folder location not anywhere on the system. – Nikita Belooussov Jun 05 '21 at 01:55
  • 2
    you probably named your file `torch.py` -- and python is case sensitive so it's `windll` not `WinDLL` – anthony sottile Jun 05 '21 at 02:00
  • @AnthonySottile nope nothing named torch in that file and the windll error comes is when I import the ctypes library, so it isnt even something that I have touched. It is also imported completely fine outside of this folder – Nikita Belooussov Jun 05 '21 at 02:05
  • @AnthonySottile thanks for the idea, I saw that I named it struct and thought that was a common enough name that it could cause some issues. – Nikita Belooussov Jun 05 '21 at 02:12

1 Answers1

0

So I was stupid and the struct.py file was interrupting the path to the correct one. Once I changed the name everything worked as it was supposed to.