1
votes

I created an environment in Anaconda3 and installed pytorch and spyder on a Linux machine. Here are the specifications:

spyder                    3.3.1  
ipython                   7.0.1  
python                    3.7.0  
pytorch                   0.4.1  
torchvision               0.2.1  

When I open spyder and import torch, it works. Afterwards I installed matplotlib 3.0.1. Restarting spyder and importing again pytorch results in a message on the ipython window in spyder:

An error ocurred while starting the kernel
terminate called after throwing an instance of 'std::runtime_error'
what(): expected ) but found 'ident' here:
aten::_addmv(Tensor self, Tensor mat, Tensor vec, *, Scalar beta=1, Scalar alpha=1) ‑> Tensor
~~~~~~ <‑‑‑ HERE

On the bash terminal, I get the message:

js: Not allowed to load local resource:   
file:///home/user/anaconda3/envs/myenv/lib/python3.7/site-packages/spyder/utils/help/static/css/default.css 

I have been using all these packages in another environment for months (so they are in an older version), so it must be something with the new versions.
If I run ipython or python on the terminal, importing works, so I am concluding it has something to do with spyder.

The 'solution' is obvious: install older versions of the packages, but is there any other more sustainable solution?

1

1 Answers

5
votes

I have ipython 7.0.1 and matplotlib 2.0.2 and the same problem, it seems like ipython crashes after the following two commands: %matplotlib auto followed by import torch.

This happens both in spyder as in jupyter notebook when the two commands are in seperate blocks.

What worked for me was: First making sure that spyders backend graphics is set to inline: Tools -> Preferences -> IPython console -> Graphics backed to Inline. Then import torch followed by switching from inline to external plotting with %matplotlib auto.

Note that this does not happen any more with ipython 7.2.0 and matplotlib 3.0.2