0

I am studying Pytorch, and I use Windows and Jupyter notebook.

When I try to import some modules like gym or cv2 on Pytorch Kernel, there are errors like 'no modules names gym'.

When I run sys.path on Pytorch there is no path "C:\Users\Myname\Anaconda3\envs\pytorch\lib\site-packages\IPython\extensions", which is there on Python3 kernel.

So I used sys.path.append to add this path and I could import the modules successfully.

But is there a way to add this path permanently to my sys.path on Pytorch? Or should I type sys.path.append every time I run the different code?

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
456 123
  • 111
  • 1
  • 4

1 Answers1

2

C:\Users\Myname\Anaconda3\envs\pytorch\lib\site-packages\IPython\extensions is a path from a virtualenv pytorch. You need to activate it in the Anaconda prompt before running a kernel:

C:\> C:\Users\Myname\Anaconda3\envs\pytorch\Scripts\activate

(pytorch) C:\> 

If you need to run something (semi-)automatically in this environment, see How to make batch files run in anaconda prompt.

If you need jupyter in this environment, you'll need to install corresponding conda packages into it.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152