1
votes

I am a newbie and the following question may be dumb and not well written. I tried the following block of codes in Ipython:

%pylab qt5
x = randn(100,100)
y = mean(x,0)
import seaborn
plot(y)

And it delivered a plot. Everything was fine.

However, when I copied and pasted those same lines of codes to Pycharm and tried running, syntax error messages appeared.

For instance,

  • %pylab was not recognized.
  • Then I tried to import numpy and matplotlib one by one. But then, randn(.,.) was not recognized.
1
%pylab is a magic function in ipython this is why it doesn't work in Pycharm - EdChum
How about calling functions like "randn"? I think the standard is np.random or so? So, codes written with Pycharm editor and can run there can run in Ipython, but not vice versa? - user76911
You will need to do np.random.randn() - DavidG
Ipython magic functions only work in ipython - juanpa.arrivillaga

1 Answers

0
votes

You can use IPython/Jupyter notebooks in PyCharm by following this guide: https://www.jetbrains.com/help/pycharm/using-ipython-jupyter-notebook-with-pycharm.html

You may modify code like the snippet below in order to run in PyCharm:

from numpy.random import randn
from numpy import mean
import seaborn

x = randn(10, 10)
y = mean(x, 0)

seaborn.plt.plot(x)
seaborn.plt.show()