2

Every time I try to create a new environment with anaconda in the Windows Command Prompt I get this error:

File "<stdin>", line 1
  conda create -n 11 python=3.6
             ^

SyntaxError: invalid syntax

I use this command to create the environment:

conda create -n 11 python=3.6

Screenshot of error in command prompt

gsquaredxc
  • 1,024
  • 12
  • 28
Toka A. Amin
  • 156
  • 1
  • 2
  • 16

3 Answers3

5

You are supposed to use a terminal not the Python interpreter to execute those commands.

Search for terminal in search menu of you computer (cmd on Windows, terminal on Linux) and open that then try those commands and it should work.

Just make sure that it is not the Python interpreter (it will not have >>>) or a Python script.

Xantium
  • 11,201
  • 10
  • 62
  • 89
  • Thank you. i typed the command in cmd and anaconda prompt and i got "conda is not recognized as an internal or external command " error – Toka A. Amin Mar 03 '18 at 19:56
  • 1
    @tokaaliamien You will need to add it to path then. See https://stackoverflow.com/questions/28612500/why-anaconda-does-not-recognize-conda-command – Xantium Mar 03 '18 at 20:01
  • If you have indeed installed it :-) if not see https://conda.io/docs/user-guide/install/index.html and the problem should be fixed – Xantium Mar 03 '18 at 20:01
  • @tokaaliamien No problem, like `pip` it is important to read the documentation very carefully to see how it should be used, if you are not sure trying both is often a good idea, also another rule is to remember that Python commands often require `()`, those to be run in a terminal generally do not so that might be a way to differentiate between the two. :-) – Xantium Mar 03 '18 at 20:08
0

Open Anaconda prompt terminal NOTE: Run as administrator or it will fail after wasting your time.

type: conda create -n 11 python=3.6

follow the console instructions

Community
  • 1
  • 1
Alfred Udah
  • 141
  • 1
  • 4
0

make sure to use the terminal as a previous comment said.

In case you use VS Code, you can just type exit() in the python interpreter section to get back to the terminal/Powershell session.

Varad
  • 920
  • 10
  • 25
steelm
  • 1
  • 1