Search code examples
pythonnumpyjupyter-notebookpytorchipython

Unable to import anything in itorch notebook


I have installed IPython notebook,torch and Itorch on my Ubuntu 16.04. I open an iTorch notebook using:

itorch notebook

In the notebook I am able to use:

require 'nn'
nn.Sequential() 
nn.SpatialConvolution(1, 6, 5, 5)

Basically I am able to use the functions of torch. But when I import any python library as numpy or pandas:

import numpy as np

I get the following error:

[string "import numpy as np..."]:1: syntax error near 'numpy'

Even when i run itorch in terminal I get the same error. Plz help.


Solution

  • Multilingual notebooks turned out to be very complicated to implement, so Jupyter notebooks can only use one language at a time. See e.g. here. Unless iTorch defines a magic or something for using Python too, there's no way to use both in the same notebook. Sorry.