1

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!

jax
  • 17
  • 6
  • Those instructions are for bash. If you're on Windows, you're probably using cmd (the normal "DOS prompt" shell) or PowerShell, so you have to adapt them (or you have to run bash for Windows instead). – abarnert May 22 '18 at 23:39
  • The cmd equivalent to `export` is `SET`, but there is no cmd equivalent to backticking `pwd`. The simplest thing to do is past the path in explicitly. If you're in `C:\Spam\Eggs\spaCy>`, something like `SET PYTHONPATH="C:\Spam\Eggs\spaCy"` (not tested, since I don't have a Windows machine around). If you need more help using the Windows shell, you should probably look on Super User rather than here. But hopefully you don't need anything more complicated than that. – abarnert May 22 '18 at 23:41
  • If you need more help using the Windows shell, you should probably look on Super User rather than here. But hopefully you don't need anything more complicated than that. – abarnert May 22 '18 at 23:42
  • This seemed to work but I got this error - Command "c:\users\jacqu\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\jacqu\\AppData\\Local\\Temp\\pip-install-hng28kq3\\preshed\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\jacqu\AppData\Local\Temp\pip-record-ub15gqm_\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\jacqu\AppData\Local\Temp\pip-install-hng28kq3\preshed\ – jax May 22 '18 at 23:55
  • any ideas where to go from there? Sorry it's super long and jumbly. I'll also go check out Super User. – jax May 22 '18 at 23:55
  • Putting output like that in comments is useless. That's also a completely different problem from the one you're asking about in your question, which means that instead of everyone on Stack Overflow seeing it, only the two or three people already looking at your existing question will see it, which drastically reduces the chances of you getting an answer. Take what you have now, whip it into shape as a [mcve] if necessary, and post a brand new question. – abarnert May 22 '18 at 23:57

1 Answers1

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.

abarnert
  • 354,177
  • 51
  • 601
  • 671