1

Here is the complete code that I typed in:

input:

conda create --name my_app27 python=2.7 flask sqlalchemy --yes

source activate my_app27

output:

File "<ipython-input-2-9a6e240537c9>", line 1
    source activate my_app27
                  ^
SyntaxError: invalid syntax

And then I tried another one

input:

conda activate my_app27

output:

    CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
    To initialize your shell, run
    
        $ conda init <SHELL_NAME>
    
    Currently supported shells are:
      - bash
      - fish
      - tcsh
      - xonsh
      - zsh
      - powershell
    
    See 'conda init --help' for more information and options.
    
    IMPORTANT: You may need to close and restart your shell after running 'conda init'.


Note: you may need to restart the kernel to use updated packages.

Why is that?? What should I do if I get a syntax Error by activating the environment?

Huiying Chen
  • 11
  • 1
  • 3
  • 1
    Why you not just run as Administrator: `conda init powershell`. I suppose you are on Windows. – Carlo Zanocco Jul 10 '20 at 12:34
  • I'm using Mac. I run this code and then nothing happened. What's next? – Huiying Chen Jul 10 '20 at 12:37
  • If you use Mac maybe is better to run `conda init bash`, after that restart the terminal. If it doesn't work, restart the laptop. You can also try to run: `source /Users/yourUsername/anaconda3/etc/profile.d/conda.sh`. Can you please share your conda PATH? – Carlo Zanocco Jul 10 '20 at 12:39
  • You need to run the command at an operating system shell **before** starting Python, not type it into a Python shell. – Charles Duffy Jul 11 '20 at 22:05

1 Answers1

-3

Instead of source activate my_shell type conda activate my_shell.

Natsfan
  • 4,093
  • 3
  • 22
  • 29
  • `SyntaxError: invalid syntax` is an error from a Python interpreter, not from a shell. `conda activate` won't work in a Python interpreter any more than `source activate` will. – Charles Duffy Jul 11 '20 at 22:07