2013-02-16 10 views
5

Ho installato SCons 2.2.0 in Python 2.7 su Windows 7. Quando eseguo "scons" da cmd ottengo il messaggio di errore "scons non riconosciuto e comando interno o esterno" Come posso risolvere questo?Running Scons 2.2.0 su Windows 7 cmd


Il problema è scons-2.2.0-setup.exe non ha impostato il percorso nel sistema. Scons.bat e scons-2.2.0.bat si trovano entrambi nella cartella "C:/Python27/Scripts". L'impostazione di questo percorso risolve il problema. Ora sorge un nuovo problema quando si prova a compilare un semplice file C++ con il messaggio "cl" non riconosciuto come comando interno o esterno. (Windows 7 a 64 bit). Per favore qualche idea può essere d'aiuto.

risposta

6

Lo hai installato utilizzando lo SCons windows installer? Dovrebbe impostare tutto per te.

Secondo il SCons installation instructions, SCons deve essere installato qui:

  • C: \ Python25 \ Scripts
  • C: \ Python25 \ scons

Nel tuo caso, sostituire c:\Python25 con la posizione dell'installazione di pythong 2.7.

Inoltre, assicurati che lo script python di SCons sia nel tuo percorso. Potrebbe essere necessario riavviare il cmd per rendere effettive le modifiche al percorso.

+0

da quella pagina ho ottenuto scons scons-2.2.0-setup.exe per Windows e non è mai impostare il percorso per me e io non riesci a trovare uno scons specifico eseguibile per il percorso! – Amani

+0

Link non funziona (più). Ecco la pagina di download generica: http://www.scons.org/download.php – Geier

1

Per utilizzare cl è necessario utilizzare la riga di comando di Visual Studio e quindi eseguire scons da lì, il suo file .bat e la cartella degli script nell'installazione di Python. Mettere degli script nel tuo percorso dovrebbe risolverlo come ho fatto io di recente.

0

Ho installato la versione più recente (3.0.0 e 3.0.1).

stesso problema, forse perché

  1. Il programma di installazione di Windows era alla ricerca di un'installazione di Python all'interno C:/Program Files ... e potrebbe trovare Python 3.x solo (che non è compatibile)

  2. setup.py ha un piccolo problema.

In ogni caso, sono arrivato con la seguente soluzione.

  1. installazione con python setup.py install
  2. Vai alla directory di installazione di Python
  3. mettere uno (o entrambi) dei seguenti file nella sottocartella Scripts:

    • scons.bat se si esegue scons da cmd
    • .210 se si esegue scons da Msys o Cygwin

ho messo sotto il codice di questi 2 script (la .bat faceva parte della sorgente e la .sh è stato ispirato da esso).

File <Python_dir>/Scripts/scons.bat

@REM Copyright (c) 2001 - 2017 The SCons Foundation 
@REM src/script/scons.bat rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog 
@echo off 
set SCONS_ERRORLEVEL= 
if "%OS%" == "Windows_NT" goto WinNT 

@REM for 9x/Me you better not have more than 9 args 
python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.0.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-3.0.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9 
@REM no way to set exit status of this script for 9x/Me 
goto endscons 

@REM Credit where credit is due: we return the exit code despite our 
@REM use of setlocal+endlocal using a technique from Bear's Journal: 
@REM http://code-bear.com/bearlog/2007/06/01/getting-the-exit-code-from-a-batch-file-that-is-run-from-a-python-program/ 

:WinNT 
setlocal 
@REM ensure the script will be executed with the Python it was installed for 
set path=%~dp0;%~dp0..;%path% 
@REM try the script named as the .bat file in current dir, then in Scripts subdir 
set scriptname=%~dp0%~n0.py 
if not exist "%scriptname%" set scriptname=%~dp0Scripts\%~n0.py 
python "%scriptname%" %* 
endlocal & set SCONS_ERRORLEVEL=%ERRORLEVEL% 

if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto returncode 
if errorlevel 9009 echo you do not have python in your PATH 
goto endscons 

:returncode 
exit /B %SCONS_ERRORLEVEL% 

:endscons 
call :returncode %SCONS_ERRORLEVEL% 

File <Python_dir>/Scripts/scons

#!/bin/bash 

# Script to launch scons from MSys or Cygwin 
# Inspired by scons.bat delivered with SCons 

# Ensure the script will be executed with the Python it was installed for 
BASEDIR=$(dirname "$0") 
PATH="$BASEDIR:$BASEDIR/..:$PATH" 

# Try the script named as the .bat file in current dir, then in Scripts subdir 
BASENAME=$(basename "$0") 
SCRIPT=${BASENAME%.*} 
SCRIPTNAME="$BASEDIR/$SCRIPT.py" 
if ! [ -f "$SCRIPTNAME" ]; then 
    SCRIPTNAME="$BASEDIR/Scripts/$SCRIPT.py" 
fi 

# Run 
python "$SCRIPTNAME" [email protected] 
SCONS_ERRORLEVEL=$? 

# Check error code 
if [ SCONS_ERRORLEVEL == 9009 ]; then 
    echo "You do not have python in your PATH" 
fi 

# End 
exit $SCONS_ERRORLEVEL