2

Python 3.7.0, Spyder 3.7, macOS High Sierra

In the terminal, I activate the environment in which torch is installed, and then when I start python within the terminal (just by $python), I can import torch and work with it. However, when I open Spyder in the same environment ($spyder), it won't import torch, because it cannot find it for some reason.

I've tried out most things on the first couple of pages of google when you search this problem, including creating a new environment, tried both pip and conda installs, updated conda and spyder.

The errormessage I get is simply:

ModuleNotFoundError: No module named 'torch'

Does anyone know how I can fix this?

isabel
  • 21
  • 2
  • 1
    print sys.path both from terminal and from spider, then figure out what is the difference. – unlut Jul 02 '19 at 11:18
  • You are right! The paths are different. Do you have any idea how that is possible when you open it from a certain environment in the terminal, and how to change it? Selecting the option "Use the following Python interpreter:" (preferences --> Python interpreter) and pasting the correct path did not work... – isabel Jul 02 '19 at 15:30
  • Is this issue similar to yours maybe? https://stackoverflow.com/questions/10729116/adding-a-module-specifically-pymorph-to-spyder-python-ide – unlut Jul 02 '19 at 15:51
  • Yeah it's similar, but the suggested solution doesn't seem to work unfortunately. I've now used a very ugly workaround: I just installed torch in the path that spyder was using, but at least I can work on! – isabel Jul 03 '19 at 07:54
  • (*Spyder maintainer here*) Please read [our guide](https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder) on how to work with environments. – Carlos Cordoba Jul 04 '19 at 16:49

0 Answers0