Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pip install pythonnet fails on Win7 32 bit #1611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DareDevilDenis opened this issue Oct 25, 2021 · 7 comments
Closed

pip install pythonnet fails on Win7 32 bit #1611

DareDevilDenis opened this issue Oct 25, 2021 · 7 comments

Comments

@DareDevilDenis
Copy link

Question before getting into the details: Does Python.Net 3.0 support 32 bit Windows OS? If so, please see details below.

Environment

  • Pythonnet version: Using command today (25 Nov):

pip install git+https://github.com/pythonnet/pythonnet

  • Python version: 3.8.10 (last version to support Win 7)
  • Python packages already installed:
C:\windows\system32>py -m pip list
Package       Version
------------- -------
pip           21.3.1
setuptools    56.0.0
wheel         0.37.0

  • Operating System: Win7 32 bit
  • .NET Runtime: 5.0.11 32 bit

Details

  • Describe what you were trying to get done.

Trying to install Python.Net

  • Output:
C:\windows\system32>pip install git+https://github.com/pythonnet/pythonnet
Collecting git+https://github.com/pythonnet/pythonnet
  Cloning https://github.com/pythonnet/pythonnet to c:\users\vincluff\appdata\lo
cal\temp\pip-req-build-rfj3jqz9
  Running command git clone --filter=blob:none -q https://github.com/pythonnet/p
ythonnet 'C:\Users\vincluff\AppData\Local\Temp\pip-req-build-rfj3jqz9'
  Resolved https://github.com/pythonnet/pythonnet to commit ac336a893de14aaf2c7b
795568203b48030f9006
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting clr-loader
  Using cached clr_loader-0.1.6-py3-none-any.whl (45 kB)
Collecting cffi>=1.13
  Using cached cffi-1.15.0-cp38-cp38-win32.whl (167 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Building wheels for collected packages: pythonnet
  Building wheel for pythonnet (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files\python38-32\python.exe' 'c:\program files\python38
-32\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel
'C:\Users\vincluff\AppData\Local\Temp\tmpizpuo18y'
       cwd: C:\Users\vincluff\AppData\Local\Temp\pip-req-build-rfj3jqz9
  Complete output (23 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib
  copying clr.py -> build\lib
  creating build\lib\pythonnet
  copying pythonnet\__init__.py -> build\lib\pythonnet
  creating build\lib\pythonnet\find_libpython
  copying pythonnet\find_libpython\__init__.py -> build\lib\pythonnet\find_libpy
thon
  copying pythonnet\find_libpython\__main__.py -> build\lib\pythonnet\find_libpy
thon
  running build_dotnet
  Running dotnet build...
  C:\Program Files\dotnet\dotnet.exe build src/runtime/Python.Runtime.csproj --c
onfiguration release --output C:\Users\vincluff\AppData\Local\Temp\pip-req-build
-rfj3jqz9\build\lib\pythonnet/runtime
  Could not execute because the application was not found or a compatible .NET S
DK is not installed.
  Possible reasons for this include:
    * You intended to execute a .NET program:
        The application 'build' does not exist.
    * You intended to execute a .NET SDK command:
        It was not possible to find any installed .NET SDKs.
        Install a .NET SDK from:
          https://aka.ms/dotnet-download
  error: command 'C:\\Program Files\\dotnet\\dotnet.exe' failed with exit status
 -2147450735
  ----------------------------------------
  ERROR: Failed building wheel for pythonnet
Failed to build pythonnet
ERROR: Could not build wheels for pythonnet, which is required to install pyproj
ect.toml-based projects
@filmor
Copy link
Member

filmor commented Oct 25, 2021

It tells you the error explicitly, something is off with your .NET installation.

Could not execute because the application was not found or a compatible .NET S
DK is not installed.
  Possible reasons for this include:
    * You intended to execute a .NET program:
        The application 'build' does not exist.
    * You intended to execute a .NET SDK command:
        It was not possible to find any installed .NET SDKs.
        Install a .NET SDK from:
          https://aka.ms/dotnet-download

@filmor filmor closed this as completed Oct 25, 2021
@DareDevilDenis
Copy link
Author

Hi @filmor. It's a fresh install of .NET 5.0.11:

C:\>dotnet --info

Host (useful for support):
  Version: 5.0.11
  Commit:  f431858f8b

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

@lostmsu
Copy link
Member

lostmsu commented Oct 25, 2021

No SDKs were found.

@DareDevilDenis
Copy link
Author

Apologies @filmor - I thought that just having only the .NET runtime was needed. I've now installed the SDK:

C:\windows\system32>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.402
 Commit:    e9d3381880

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x86
 Base Path:   C:\Program Files\dotnet\sdk\5.0.402\

Host (useful for support):
  Version: 5.0.11
  Commit:  f431858f8b

.NET SDKs installed:
  5.0.402 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

I now get the following error:

C:\windows\system32>pip install git+https://github.com/pythonnet/pythonnet
Collecting git+https://github.com/pythonnet/pythonnet
  Cloning https://github.com/pythonnet/pythonnet to c:\users\vincluff\appdata\local\temp\pip-req-bui
ld-ril6yy63
  Running command git clone --filter=blob:none -q https://github.com/pythonnet/pythonnet 'C:\Users\v
incluff\AppData\Local\Temp\pip-req-build-ril6yy63'
  Resolved https://github.com/pythonnet/pythonnet to commit ac336a893de14aaf2c7b795568203b48030f9006

  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting clr-loader
  Using cached clr_loader-0.1.6-py3-none-any.whl (45 kB)
Collecting cffi>=1.13
  Using cached cffi-1.15.0-cp38-cp38-win32.whl (167 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Building wheels for collected packages: pythonnet
  Building wheel for pythonnet (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files\python38-32\python.exe' 'c:\program files\python38-32\lib\site-package
s\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\vincluff\AppData\Local\Temp\tm
p0xjrt28b'
       cwd: C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63
  Complete output (53 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib
  copying clr.py -> build\lib
  creating build\lib\pythonnet
  copying pythonnet\__init__.py -> build\lib\pythonnet
  creating build\lib\pythonnet\find_libpython
  copying pythonnet\find_libpython\__init__.py -> build\lib\pythonnet\find_libpython
  copying pythonnet\find_libpython\__main__.py -> build\lib\pythonnet\find_libpython
  running build_dotnet
  Running dotnet build...
  C:\Program Files\dotnet\dotnet.exe build src/runtime/Python.Runtime.csproj --configuration release
 --output C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63\build\lib\pythonnet/runtime

  Welcome to .NET 5.0!
  ---------------------
  SDK Version: 5.0.402

  Telemetry
  ---------
  The .NET tools collect usage data in order to help us improve your experience. It is collected by
Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELE
METRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

  Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

  ----------------
  Installed an ASP.NET Core HTTPS development certificate.
  To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
  Learn about HTTPS: https://aka.ms/dotnet-https
  ----------------
  Write your first app: https://aka.ms/dotnet-hello-world
  Find out what's new: https://aka.ms/dotnet-whats-new
  Explore documentation: https://aka.ms/dotnet-docs
  Report issues and find source on GitHub: https://github.com/dotnet/core
  Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
  --------------------------------------------------------------------------------------
  Microsoft (R) Build Engine version 16.11.1+3e40a09f8 for .NET
  Copyright (C) Microsoft Corporation. All rights reserved.

    Determining projects to restore...
    Restored C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63\src\runtime\Python.Runtime.
csproj (in 4.63 sec).
  C:\Users\vincluff\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.
targets(24,5): error : Error reading git repository information: Unsupported repository version 1. O
nly versions up to 0 are supported. [C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63\src
\runtime\Python.Runtime.csproj]
  C:\Users\vincluff\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.
targets(24,5): warning : Unable to locate repository with working directory that contains directory
'C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63\src\runtime'. [C:\Users\vincluff\AppDat
a\Local\Temp\pip-req-build-ril6yy63\src\runtime\Python.Runtime.csproj]

  Build FAILED.

  C:\Users\vincluff\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.
targets(24,5): warning : Unable to locate repository with working directory that contains directory
'C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63\src\runtime'. [C:\Users\vincluff\AppDat
a\Local\Temp\pip-req-build-ril6yy63\src\runtime\Python.Runtime.csproj]
  C:\Users\vincluff\.nuget\packages\microsoft.build.tasks.git\1.0.0\build\Microsoft.Build.Tasks.Git.
targets(24,5): error : Error reading git repository information: Unsupported repository version 1. O
nly versions up to 0 are supported. [C:\Users\vincluff\AppData\Local\Temp\pip-req-build-ril6yy63\src
\runtime\Python.Runtime.csproj]
      1 Warning(s)
      1 Error(s)

  Time Elapsed 00:00:06.28
  error: command 'C:\\Program Files\\dotnet\\dotnet.exe' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pythonnet
Failed to build pythonnet
ERROR: Could not build wheels for pythonnet, which is required to install pyproject.toml-based proje
cts

I don't know if this is relevant to this issue, but I noticed that in
https://github.com/pythonnet/clr-loader/blob/master/clr_loader/util/find.py
it checks environment variable "ProgramFiles(x86)" however on 32bit Windows I don't think this variable is available so it will never get the path.

def find_dotnet_root() -> str:
    dotnet_root = os.environ.get("DOTNET_ROOT", None)
    if dotnet_root is not None:
        return dotnet_root

    if sys.platform == "win32":
        # On Windows, the host library is stored separately from dotnet.exe for x86
        if sys.maxsize > 2 ** 32:
            prog_files = os.environ.get("ProgramFiles")
        else:
            prog_files = os.environ.get("ProgramFiles(x86)")    <--- doesn't exist on Win32

@filmor
Copy link
Member

filmor commented Oct 26, 2021

Your git installation seems to be messed up, maybe check it out manually and install from the checkout (pip install .). If the posted code poses a problem for you, please create an issue on the clr-loader project.

@DareDevilDenis
Copy link
Author

It worked using manual check out followed by pip install . Thanks 👍
Since it works this way I'll forget about getting it working using git, but it's strange why it didn't work as I have the latest version from https://git-scm.com/download/win

>git --version
git version 2.33.1.windows.1

About the posted, code: As suspected, when running on 32 bit Windows, when my code calls:

config_path = get_coreclr(r'C:\MyApp.runtimeconfig.json')

It throws exception:

Traceback (most recent call last):
  File "MyApp.py", line 10, in <module>
    config_path = get_coreclr(r'C:\MyApp.runtimeconfig.json')
  File "C:\Program Files\Python38-32\lib\site-packages\clr_loader\__init__.py", line 38, in get_coreclr
    dotnet_root = find_dotnet_root()
  File "C:\Program Files\Python38-32\lib\site-packages\clr_loader\util\find.py", line 19, in find_dotnet_root
    dotnet_root = os.path.join(prog_files, "dotnet")
  File "C:\Program Files\Python38-32\lib\ntpath.py", line 78, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

This is because clr_loader/util/find.py tries to read environment variable "ProgramFiles(x86)" but it doesn't exist on 32 bit Windows.

As you suggested, I've raised the issue in clr_loader: pythonnet/clr-loader#14

Has Python.Net 3.0 been tested on 32 bit Windows?

@filmor
Copy link
Member

filmor commented Nov 14, 2021

@DareDevilDenis Regarding the initial problems building from git, this is fixed now on master after people found the problem in #1613.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants