Windows系统下从源码安装Python3的Spacy时执行export命令报错
export Error When Installing spaCy from Source on Windows Hey there! Let's sort out that export command error you're facing while installing spaCy from source on Windows. The problem is straightforward: export is a command for Linux/Mac shells, but Windows Command Prompt and PowerShell use their own syntax for environment variables. Here's a step-by-step solution:
1. Find Your pwd Equivalent Path
First, you need the full path to your spaCy source code directory (this is what pwd returns on Unix systems):
- In Command Prompt: Run
cdwithout any arguments to see your current directory path, or just check the top bar of the Command Prompt window. - In PowerShell: Run
pwddirectly—it will output the full absolute path to your current working directory. Copy this path (it should be the folder where you cloned or extracted spaCy's source code, which contains thesetup.pyfile).
2. Set PYTHONPATH Temporarily (For Current Session Only)
Replace the Unix-style export PYTHONPATH=pwd command with the Windows-specific version:
- For Command Prompt:
Replaceset PYTHONPATH=C:\full\path\to\your\spacy\sourceC:\full\path\to\your\spacy\sourcewith the actual path you copied in step 1. - For PowerShell:
$env:PYTHONPATH = "C:\full\path\to\your\spacy\source"
3. Set PYTHONPATH Permanently (Persists Across Sessions)
If you want this path to be available every time you open a terminal or IDE:
- Right-click "This PC" → Select "Properties" → Click "Advanced system settings" → Open the "Environment Variables" window.
- Under "User variables" (for your account only) or "System variables" (for all users), click "New".
- Variable name:
PYTHONPATH - Variable value: Paste the full path to your spaCy source directory (e.g.,
C:\Users\jax\spacy)
- Variable name:
- Click "OK" to save all changes, then restart your terminal or IDE for the setting to take effect.
4. Verify the Setup Worked
To make sure Python can find your spaCy source code:
Open a Python shell or your IDE and run:
import sys print(sys.path)
Check if your spaCy source directory path appears in the output. If it does, you're good to go with the remaining installation steps (like pip install -e .).
内容的提问来源于stack exchange,提问作者jax

