5

I've been trying to get SCons to work on the Windows 10 cmd for some time now. I installed it through pip, so I believe it is in the correct directory because python is working in cmd when I use py. When I try to use scons, I get the message

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

Because of that, I tried editing the user and system path variable to include scons under the directory 'C:\Users\dwayn\AppData\Local\Programs\Python38\Lib\site-packages\scons\', but I get the same error.

What should I edit to make scons run on the command line?

Note: I do have Anaconda 3 installed on my system if that effects anything.

David Buck
  • 3,752
  • 35
  • 31
  • 35
D Brown
  • 51
  • 1
  • 3

5 Answers5

9

I was stuck on this too - quick answer here because the documentation around this area is pretty awful:

  • Install python, including pip and tick 'add python to PATH'
  • Run pip install scons in command line. This installs Scons, but it won't be available from command line yet
  • If you run pip show scons it'll show you where the Scons code actually is (for me it's c:\users\username\appdata\roaming\python\python38\site-packages - but this is not what you want to add to your path
  • The Windows version of Scons runs through a wrapper .exe (historically this was a .bat file so there's posts everywhere saying to just 'find scons.bat'... which doesn't exist)
  • This wrapper program scons.exe is located in the Scripts folder of your python install - so with a generic install of Python 3.8 it would be here: C:\Users\username\AppData\Roaming\Python\Python38\Scripts - here you should find the scons wrapper
    • This Scripts folder could be in a variety of places depending on how you installed python, and what version you have - If you can't find it there then also try places like C:\Python27\Scripts, C:\Program Files (x86)\Python38-32\Scripts, etc
  • Add this folder to you PATH variable
  • Restart cmd to pick this change up, and run where scons to check if it worked - this should return the filepath to scons.exe

You should now be able to run scons from command line

John
  • 500
  • 4
  • 15
  • When I downloaded scons as a .zip file from the scons website, I didn't find any .exe file, but I did find a scons.bat flie. So it appears that you'll get either a .bat or an .exe file depending on how you originally access scons. – KBurchfiel Jun 02 '22 at 22:51
0

Most likely you need to add:

C:\Users\dwayn\AppData\Local\Programs\Python38\Scripts

to your path.

bdbaddog
  • 3,357
  • 2
  • 22
  • 33
  • I have that in my path, but that unfortunately didn't do it :( – D Brown Nov 29 '19 at 01:23
  • search for scons.bat do you see any under your python tree? Do you have other pythons installed? Is it possible you ended up installing it with another python's pip? – bdbaddog Nov 29 '19 at 02:13
  • I do have multiple version of python installed, but I believed it installed with 3.8's pip because the bat is in the tree. The directory for the batch file is specifically ../Python38/Scripts/, so I'll try adding that to the path variable. @bdbaddog – D Brown Nov 29 '19 at 02:28
  • As a mostly non-scons part of the answer: current Python doesn't put the location of its binary in the path by default, but there's a box to tick in the installer. Instead you should use the python launcher (`py`), which does go in your path. If you *do* tick the box to add to PATH, it still doesn't put the Scripts subdir in the path; that you have to do manually. You're expected to run things even w a script in Scripts as `py -m module`, so installs should look like `py -m pip install scons` - now you're sure it's the right place. Unfortunately, scons can't launch via `py -m scons`... – Mats Wichmann Nov 29 '19 at 19:29
0

On my system, I have Python 3.8 installed in C:\Python38. During the install using the exe installer, I checked the box to add Python to the system path. I then installed scons, which also goes into that location. Running scons didn't work at first (as it had with previous version installs) and I found that the paths that the Python installer added needed to be flipped. It needed to be C:\Python38;C:\Python38\Scripts;%PATH%. The reason is because scons.bat is in C:\Python38 and scons.py is in C:\Python38\Scripts. To run scons, it needs to find scons.bat first.

My suggestion is to make sure you have those two paths (wherever they are) in your system environment path such that the path to scons.bat comes first and make sure these come before any paths for other Python installs.

Kurt
  • 1
  • 3
  • on my windows 10 : pip install scons Requirement already satisfied: scons in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages (4.2.0) Requirement already satisfied: setuptools in c:\program files\windowsapps\pythonsoftwarefoundation.python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\site-packages (from scons) (47.1.0) C:\Temp\wiredtiger\wiredtiger>C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\scons.exe is this normal ? – user3181125 Sep 09 '21 at 17:54
0

I had downloaded scons onto my Windows computer by downloading the zip file provided at https://scons.org/pages/download.html . (In my case, this file was named scons-4.2.0.zip). After downloading and unzipping it, I had a 'socns-local-4.2.0' folder in my Downloads folder which contained both scons.bat and scons-4.2.0.bat. (I didn't find any .exe file within the downloaded folder; perhaps this is only produced when users install it via Python.)

To resolve the error message shown in the question, I went to Edit System Environment Variables within the Control Panel (as suggested in earlier answers) and added the scons-4.2.0 folder (located, in my case, at C:\Users<my_username>\Downloads\scons-local-4.2.0) to my system path. (It wasn't necessary to do this for my user path.)

After doing so, I no longer received the error message quoted in the question.

KBurchfiel
  • 635
  • 6
  • 15
0

Depending on where you get SCons from a wrapper might not be included. In those cases running it via python -m SCons command should work.

Note it is case sensitive and needs to match the name in the installation folder, which you can display using: python -m pip show scons

G.G
  • 899
  • 6
  • 15