简体   繁体   中英

Cannot install spacy for Python using Anaconda

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!

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM