如何在Python 3.6的Scripts文件夹外创建Scrapy项目?
Hey there! I totally get the frustration—when you're used to working within Spyder/Anaconda's GUI, suddenly having to mess with command line paths can feel confusing. Let's break down why you had to navigate to the Scripts folder, and how to fix it so you can create Scrapy projects anywhere you want.
Why This Happened
The core issue is that your system's PATH environment variable doesn't include Anaconda's Scripts directory. When you run a command like scrapy in the console, Windows looks through all the folders listed in PATH to find the executable file (scrapy.exe). Since it wasn't in PATH, you had to go directly to the folder where scrapy.exe lives (the Scripts directory) to run it.
Fix 1: Temporary Solution (Per Session)
If you just want a quick fix for the current console session, you can add the Scripts path to PATH temporarily:
- Open Anaconda Prompt like you normally do.
- Instead of navigating to the Scripts folder, run this command first:
set PATH=%PATH%;C:\Users\jecon\Anaconda3\Scripts - Now you can navigate to any folder where you want to create your Scrapy project, for example:
cd "C:\Users\jecon\Documents\MyScrapyProjects" - Then run the Scrapy command like normal:
scrapy startproject tutorial
This will only work for that specific console window—you'll have to repeat the PATH command if you open a new one.
Fix 2: Permanent Solution (Set It Once)
For a long-term fix, add the Scripts directory to your system's PATH permanently:
- Press
Win + Rto open the Run dialog, typesysdm.cpl, and hit Enter. - In the System Properties window, go to the Advanced tab and click Environment Variables.
- In the "System Variables" section, find the
Pathvariable, select it, and click Edit. - Click New and paste in the full path to your Anaconda Scripts folder:
C:\Users\jecon\Anaconda3\Scripts - Click OK on all open windows to save the changes.
- Restart your Anaconda Prompt (or any console you use)—from now on, you can run
scrapycommands from any folder on your system.
Bonus: If You Use Anaconda Virtual Environments
If you're working with virtual environments (which is a great practice!), each environment has its own Scripts folder (e.g., C:\Users\jecon\Anaconda3\envs\myenv\Scripts). Instead of adding this to your system PATH, just activate the environment first:
conda activate myenv
Once activated, the environment's Scripts directory is automatically added to your PATH temporarily, so you can run scrapy commands right away without extra steps.
内容的提问来源于stack exchange,提问作者Juan C

