Can not actiavte a conda environment in jupyter

Anaconda and pytorch where first installed. Then I a started jupyter notebook and a python3 notebook. The command “conda activate pytorch” gives an error message:
https://s9.gifyu.com/images/SVe2l.png

How do I activate a conda environment?

Sven

That isn’t where you want to be doing this. What are you using a guide to how to use Anaconda/conda? Did you work through the Anaconda-provided guide to using it?

Here in the ‘Getting Started’, under ’ Starting conda’ it tells you how to do start with all three systems:

  • Windows: “Open either the Command Prompt (cmd.exe) or PowerShell.”
  • MacOS: …a couple of steps… and then “Open the Terminal application.”
  • Linux: “Open a terminal window.”

(My under standing from here and here is that you can use the Anaconda prompt, too. If you have that and/or are working on Windows.)

Then below that on that page is the ‘Creating environments’ initial getting-started’ step. Meaning you needed to do the steps above to get ready to do those.

Similarly, elsewhere in the documentation is ‘Managing environments’, where it says “Use the terminal for the following steps”.


With the environments then made, subsequently you can then choose them when you open Jupyter using the Anaconda-described routes for launching Jupyter. Here’s the options for opening in Windows.

If you want to do more complex routes or troubleshoort, see here or here.


You can use some conda commands in a Jupyter notebook with the help of the magic symbol, like %conda install ... or %conda list. However, you need an active terminal/console session to initialize and activate an environment because the active environment session is attached to that active console.
This wouldn’t happen when you try it in Jupyter because console commands get run off in a temporary shell session that gets ended after it running. This there is nothing to bind your environment-use session, too.

1 Like

Thank you very much for your time and effort to write this. I am still reading and fighting my way through the tutorials. Will try and follow it.

Do you mind writing more question to you here?
I am working on a MAC 10.15

Best regards
Sven

Thank you fomightez,

This did fix the problem. Great.

Regards
Sven

1 Like