Installing Spacy for NLP with Python 3 & Windows gives error when installing from source

雨燕双飞 提交于 2019-12-11 10:51:33

问题


I'm following the directions Spacy gives to install for Windows, Python 3, and from source (pip and conda have both given me errors that I've still been unable to resolve, directly from source seems to get the closest to actually installing). However, when I get to step 3 and enter export PYTHONPATH = pwd in the command line (with the quotes around pwd like it wants, it just messes up the formatting here), I get this error message:

export is not recognized as an internal or external command, operable program, or batch file.

I've read that how to fix this error in the past is to add a path through the environmental variables option, however I'm not sure what that would look like here. I'm not sure what pwd is on my computer or how to get a path to it.

I have the newest version of python 3 (just downloaded today), as well as microsoft visual studio, which is apparently needed for using Spacy. Any help would be greatly appreciated. Thanks!


回答1:


Looking at the linked install directions, if you select "from source", it seems to ignore the OS choice and give you bash-specific instructions no matter what.

While you can get and run bash for Windows, your shell is probably not bash, but cmd (aka "DOS prompt"), which is completely different.

(As a side note, those extra spaces you added around the = would make your attempt fail even if you were using bash. It's important to be exact, especially when working with languages that you don't know.)


Fortunately, what you're trying to do is very simple—just set a single environment variable for the rest of this shell session.

The rough cmd equivalent to bash's export is SET. Unfortunately, there is no rough equivalent of the backtick syntax to call pwd and stash the resulting output. The easiest thing to do here is to do it manually, by copying in the current working directory. For example:

C:\Spam\Eggs> git clone https://github.com/explosion/spaCy
C:\Spam\Eggs> cd spaCy
C:\Spam\Eggs\spaCy> SET PYTHONPATH="C:\Spam\Eggs\spaCy"
C:\Spam\Eggs\spaCy> pip install -r requirements.txt
C:\Spam\Eggs\spaCy> python setup.py build_ext --inplace

You might also want to consider using py instead of python, and running pip as a module rather than as a script:

C:\Spam\Eggs> git clone https://github.com/explosion/spaCy
C:\Spam\Eggs> cd spaCy
C:\Spam\Eggs\spaCy> SET PYTHONPATH="C:\Spam\Eggs\spaCy"
C:\Spam\Eggs\spaCy> py -m pip install -r requirements.txt
C:\Spam\Eggs\spaCy> py setup.py build_ext --inplace

But if you only have a single Python installation, and your python and pip are both working properly, this shouldn't make any difference.



来源:https://stackoverflow.com/questions/50477800/installing-spacy-for-nlp-with-python-3-windows-gives-error-when-installing-fro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!