简体   繁体   中英

Run scons on Windows 10 environment with Python 2.7 and Python 3

How can I run scons on Windows 10 when Python 3.6.1 and Python 2.7.13 is installed? When typing python into my command window I get the following output:

Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Since I personally use Python 3.6.x this is fine for me and I do not want to change this.

When typing py -2 into my command window I get the following output:

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

scons does not work with Python 3.x. It needs to be executed with Python 2.7.x. How can I "tell" scons to use Python 2.7.x?

When I just type scons into the command prompt I get the following output:

PS C:\dev\projectX> scons
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007050 (most recent call first):

Try Changing line 23 in scons.bat from:

python "%scriptname%" %*

to

py -2  "%scriptname%" %*

Note that work on getting SCons to run under both py 2 and py 3.5+ is mostly done and should be released in the next month (or so)

Before running scons in Powershell, amend the PATH environment variable to put your Python 2.7 installation at the front. Something like:

SET PATH=C:\Python27;%path%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM