cpython_core_tutorial icon indicating copy to clipboard operation
cpython_core_tutorial copied to clipboard

Build CPython on Windows needs %PYTHON% to be defined

Open shireenrao opened this issue 5 years ago • 4 comments

I was trying to follow the tutorial on building cpython on windows and while running the step for installing tools and dependencies, I was seeing failures when running PCbuild\get_externals.bat. It turns out that I have to either set the environment variable PYTHON to an existing version or run PCBuild\get_externals.bat with parameter --python C:\some\path\to\python.

It would be nice to have that be part of the tutorial.

shireenrao avatar Aug 13 '19 18:08 shireenrao

Do you mean that running "python" in a terminal fails? There is no "python" in your PATH?

vstinner avatar Aug 14 '19 14:08 vstinner

I have the windows store provided python installed. When I do where python I see it available C:\Users\srao\AppData\Local\Microsoft\WindowsApps\python.exe

When I run the PCbuild\get_externals.bat this is the exact error -

C:\Users\srao\temp\scratch\cpython>PCbuild\get_externals.bat
Using py -3.7 (found 3.7 with py.exe)
Fetching external libraries...
Fetching bzip2-1.0.6...
Traceback (most recent call last):
  File "C:\Users\srao\temp\scratch\cpython\PCbuild\\get_external.py", line 60, in <module>
    main()
  File "C:\Users\srao\temp\scratch\cpython\PCbuild\\get_external.py", line 53, in main
    verbose=args.verbose,
  File "C:\Users\srao\temp\scratch\cpython\PCbuild\\get_external.py", line 20, in fetch_zip
    reporthook=reporthook,
  File "C:\Apps\Anaconda3\lib\urllib\request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "C:\Apps\Anaconda3\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Apps\Anaconda3\lib\urllib\request.py", line 525, in open
    response = self._open(req, data)
  File "C:\Apps\Anaconda3\lib\urllib\request.py", line 548, in _open
    'unknown_open', req)
  File "C:\Apps\Anaconda3\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Apps\Anaconda3\lib\urllib\request.py", line 1387, in unknown_open
    raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: https>

Giving this command succeeds - PCbuild\get_externals.bat --python C:\Users\srao\AppData\Local\Microsoft\WindowsApps\python.exe

shireenrao avatar Aug 14 '19 15:08 shireenrao

I don't know why you get this error. Maybe report the bug to bugs.python.org.

I install Python from python.org and asks the installer to put it in the PATH.

vstinner avatar Aug 14 '19 15:08 vstinner

Using py -3.7 (found 3.7 with py.exe)

I think py.exe might be picking up my anaconda python and thats why it wasnt working. When I type py.exe I see the following -

C:\Users\srao>py.exe
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>>       

Even though anaconda python is not in my path, I have a feeling py.exe might be using the registry to choose anaconda python and that doesn't work unless I start from the anaconda prompt or activate the conda environment.

shireenrao avatar Aug 14 '19 15:08 shireenrao

No activity for 4 years, I close the issue.

vstinner avatar Jan 02 '23 15:01 vstinner