Skip to content
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

TypeError in windows / msvc.py when VCRuntimeRedist is not present #1902

Closed
zzzeek opened this issue Nov 6, 2019 · 5 comments
Closed

TypeError in windows / msvc.py when VCRuntimeRedist is not present #1902

zzzeek opened this issue Nov 6, 2019 · 5 comments
Assignees

Comments

@zzzeek
Copy link

zzzeek commented Nov 6, 2019

User is reporting the below stack trace on windows. This would indicate that the method VCRuntimeRedist at https://github.com/pypa/setuptools/blob/master/setuptools/msvc.py#L1540 is returning None and the method at https://github.com/pypa/setuptools/blob/master/setuptools/msvc.py#L1574 is nonetheless assuming a non-None result.

It's very hard to find this error elsewhere but I did see it reported (and mis-diagnosed) here: https://stackoverflow.com/questions/58677600/unable-to-install-jupyterlab-for-python3-8-64bit

 Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\masma\AppData\Local\Temp\pip-install-rhpx0g7l\sqlalchemy\setup.py", line 217, in <module>
        run_setup(True)
      File "C:\Users\masma\AppData\Local\Temp\pip-install-rhpx0g7l\sqlalchemy\setup.py", line 196, in run_setup
        **kwargs
      File "c:\users\masma\source\repos\orsteddcsmarketsanalytics\apps\portfolio_analytics\tmp\.venv\lib\site-packages\setuptools\__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\masma\source\repos\orsteddcsmarketsanalytics\apps\portfolio_analytics\tmp\.venv\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\masma\AppData\Local\Temp\pip-install-rhpx0g7l\sqlalchemy\setup.py", line 54, in run
        build_ext.run(self)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\command\build_ext.py", line 339, in run
        self.build_extensions()
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\command\build_ext.py", line 448, in build_extensions
        self._build_extensions_serial()
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\command\build_ext.py", line 473, in _build_extensions_serial
        self.build_extension(ext)
      File "C:\Users\masma\AppData\Local\Temp\pip-install-rhpx0g7l\sqlalchemy\setup.py", line 60, in build_extension
        build_ext.build_extension(self, ext)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\command\build_ext.py", line 533, in build_extension
        depends=ext.depends)
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\_msvccompiler.py", line 345, in compile
        self.initialize()
      File "c:\users\masma\appdata\local\programs\python\python37\Lib\distutils\_msvccompiler.py", line 238, in initialize
        vc_env = _get_vc_env(plat_spec)
      File "c:\users\masma\source\repos\orsteddcsmarketsanalytics\apps\portfolio_analytics\tmp\.venv\lib\site-packages\setuptools\msvc.py", line 171, in msvc14_get_vc_env
        return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
      File "c:\users\masma\source\repos\orsteddcsmarketsanalytics\apps\portfolio_analytics\tmp\.venv\lib\site-packages\setuptools\msvc.py", line 1620, in return_env
        if self.vs_ver >= 14 and isfile(self.VCRuntimeRedist):
      File "c:\users\masma\source\repos\orsteddcsmarketsanalytics\apps\portfolio_analytics\tmp\.venv\lib\genericpath.py", line 30, in isfile
        st = os.stat(path)
    TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
    ----------------------------------------
@zzzeek
Copy link
Author

zzzeek commented Nov 8, 2019

multiple reports now.

@vxgmichel
Copy link

I ran into this issue too, and fixed it temporarily using:

diff --git a/setuptools/msvc.py b/setuptools/msvc.py
index 2ffe1c81..ffd01704 100644
--- a/setuptools/msvc.py
+++ b/setuptools/msvc.py
@@ -1617,7 +1617,7 @@ class EnvironmentInfo:
                                     self.FSharp],
                                    exists),
         )
-        if self.vs_ver >= 14 and isfile(self.VCRuntimeRedist):
+        if self.vs_ver >= 14 and self.VCRuntimeRedist and isfile(self.VCRuntimeRedist):
             env['py_vcruntime_redist'] = self.VCRuntimeRedist
         return env

The package (pendulum in my case) was successfully installed after this change.

sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this issue Nov 8, 2019
Added a workaround for a setuptools-related failure that has been observed
as occurring on Windows installations, where setuptools is not correctly
reporting a build error when the MSVC build dependencies are not installed
and therefore not allowing graceful degradation into non C extensions
builds.

Setuptools issue pypa/setuptools#1902

Fixes: #4967
Change-Id: I5e21e7e78cb6d927b18afce64cacf8643b98354e
sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this issue Nov 8, 2019
Added a workaround for a setuptools-related failure that has been observed
as occurring on Windows installations, where setuptools is not correctly
reporting a build error when the MSVC build dependencies are not installed
and therefore not allowing graceful degradation into non C extensions
builds.

Setuptools issue pypa/setuptools#1902

Fixes: #4967
Change-Id: I5e21e7e78cb6d927b18afce64cacf8643b98354e
(cherry picked from commit 4a2dd49)
@WilliamHPNielsen
Copy link

I ran into the same issue today (platform: Windows 10) and traced it down to the fact that my Visual Studio installation had no Redist folders. Cf. how setuptools finds the redistributable dll:

def VCRuntimeRedist(self):

I ended up re-installing Visual Studio with all C++ development enabled. After that, the package in question (wrapt in my case) could successfully be installed.

sumau pushed a commit to sumau/sqlalchemy that referenced this issue Dec 29, 2019
Added a workaround for a setuptools-related failure that has been observed
as occurring on Windows installations, where setuptools is not correctly
reporting a build error when the MSVC build dependencies are not installed
and therefore not allowing graceful degradation into non C extensions
builds.

Setuptools issue pypa/setuptools#1902

Fixes: sqlalchemy#4967
Change-Id: I5e21e7e78cb6d927b18afce64cacf8643b98354e
@davinci26
Copy link

Hey folks, I run into this error and trying to debug it because it only appears on the CI but I cant repro on my local dev box.

Is this the function that I should be looking at to figure out the way it tries to resolve the path?

def VCRuntimeRedist(self):

@jaraco
Copy link
Member

jaraco commented Sep 3, 2024

Should be fixed in v74.1.1, releasing now.

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

5 participants