1

I'm trying to install spacy for Python using Anaconda and I'm getting an odd error message:

python -m venv .env
source .env/bin/activate
conda install -c conda-forge spacy
python -m spacy download en_core_web_sm

Error Msg:

  File "<ipython-input-13-1a465315722a>", line 2
    python -m venv .env
                 ^
SyntaxError: invalid syntax

I've tried several methods and none of them are working.

Any clue how to install this?

Thanks!

rdas
  • 20,604
  • 6
  • 33
  • 46
Jason
  • 71
  • 1
  • 7
  • Which operating system and Python version are you using? Please provide more details on the directory structure too. – Param Siddharth Feb 15 '21 at 07:11
  • 1
    I'm on MacOS and using Python 3.7, but I'm using Jupiter on the browser with Anaconda from my machine – Jason Feb 15 '21 at 19:16
  • It seems like you're running those commands in the notebook directly as if they were python code, try using the terminal instead. – AMC Feb 15 '21 at 23:39

2 Answers2

1

Instead of creating virtual environment like this. There is an option to create virtual environments in Anaconda with required Python version.

conda create -n myenv python=3.8

To activate it :

source activate myenv   # (in linux, you can use . as a shortcut for "source")
activate myenv          # (in windows - note that you should be in your c:\anaconda2 directory)
Akash senta
  • 483
  • 7
  • 16
0

Try running these commands into the terminal instead of the Jupyter Notebook cells directly. If you still want to do it that way, make it right by adding a ! in the beginning.

!python -m venv .env
!source .env/bin/activate
!conda install -c conda-forge spacy
!python -m spacy download en_core_web_sm
Param Siddharth
  • 858
  • 2
  • 7
  • 20