A simple python script needs to run on a windows server with no python installed.
I used py2exe, which generated a healthy dist subdirectory, with script.exe that runs fine on the local machine.
However, when I run it on the server (Windows Server 2003 R2), it produces this:
The system cannot execute the specified program.
and ERRORLEVEL is 9020.
Any ideas?
For py2exe to work, you have to include the correct version of the Microsoft C runtime DLL with your application.
For Python2.6, this is MSVCR90.dll version 9.0.21022.8, which can be obtained from the Microsoft Visual C++ 2008 Redistributable Package:
http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
NOTE that the SP1 of this installer contains a different version of the DLL, and will not work.
I spent a while earlier this year explaining this carefully in the py2exe tutorial, so I'll just link to that:
http://www.py2exe.org/index.cgi/Tutorial#Step5
It could be missing some required DLLs. Try using depends.exe to identify what might be missing. It's probably an msvc-something-something.dll
I did not find the cause to the problem, but using python 2.5 with py2exe on the same script worked fine on the server.
I guess there is something wrong with py2exe under 2.6.
Because Python 2.6 is built against Visual Studio 2008, the target machine must also have the Visual Studio 2008 libraries, available from the Visual C++ 2008 Redistributable package.
I confirmed that on a clean build of Windows XP or Server 2003 (neither of which have the Visual Studio 2008 redistributable), a Python 2.6 py2exe executable will fail with the aforementioned error, but after installing the redistributable package, the executable runs normally.
Related
Is there any way we can convert Python scripts to executable file without getting any dll errors? I tried with pyinstaller but it does not runs easily, I am getting many different dll errors like api-ms-win-crt-runtime-l1-1-0.dll not found in different Windows systems. I even tried installing vc redistribute which seems to work on some systems but that is also not getting installed in many systems. Please help.
Here you can download the api-ms-win-crt-runtime-l1-1-0 file dll file [link][1]
Update your universal C Runtime and install windows 7 version here C runtime
download Visual C++ Redistributable Packages for Visual Studio 2013 and 2015
2013 and 2015
work?
I'm trying to compile my Python project to a Windows executable (.exe) using Nuitka. I get no errors/warnings during the compilation process, but when I'm trying to run the resulting executable I get the "C:\Python34\test.exe is not a valid win32 application" error on Windows XP and a similar one on Windows 10, too). The problem persists even when I compile a "Hello, World!" program. Interesting, that I can easily build and run C++ projects from the Visual Studio IDE on the same PC.
I'm using Windows XP (x32 bits), Python 3.4.0 and Microsoft Visual C++ 2008 Professional.
How can I solve this problem?
I have installed Microsoft Visual Studio 2010 Express instead of Microsoft Visual Studio 2008 Professional, and the problem disappeared. It looks like Nuitka just can't work with the previous version of the compiler. They even say in the docs, that Nuitka is designed for Visual Studio 2017+ (but I can't install recent versions on Windows XP), and that other versions may not work correctly.
I used tried the first steps from the Nuitka website and had the same with example 1. What I found: example 1 uses --mingw64 as option.
python -m nuitka --mingw64 hello.py
In example 2/Use Case 1 there is another option introduced:
python -m nuitka --follow-imports program.py
I only copied my hello-code from example 1 (working) and renamed it to program.py (failed - even no executable!). So I am shure, the cause will be the call and not the code.
When I entered --mingw64 to the second call it worked.
My first thought (I am new to this and no expert for nuitka) is that the second example call implicitly uses gcc. At the first time it asks for installing it and then it seems to use it. The first call seems to force mingw64 as compiler. Could also be that the sequence of path entries makes a difference. Just the first entry will be executed unless you force it via an explicit option.
I'm trying to build a simple C++ extension module for Blender through their Python API which, as of the latest version, is 3.5.3 (to my knowledge, one cannot change this). Python 3.5.3 is compiled with MSC v.1800 (i.e., Visual Studio 2013 version 12.0).
I have both Visual Studio 2013 and Visual Studio 2017 installed. When running distutils.setup(...) in my "setup.py" for the extension, it invariably finds only Visual Studio 2017, causing the build to fail (one must match the Visual Studio version to the Python version [1] ).
How can I convince distutils.setup(...) to find the Visual Studio corresponding to the Python that's running?
I tried prepending the Visual Studio 2013 path to the PATH, which does nothing. I also dug into "Lib/distutils/" to try to figure it out, but couldn't (looks like it's registry-based, not PATH-based).
[1] Or else, one gets the mysterious, undocumented error LNK1327: failure during running rc.exe. This is the entire error, though there is also a minor warning before it, which is apparently normal.
The following code sets two environment variables which were (obscurely) documented as a fallback for when the compiler detection fails.
Then, we call "vcvarsall.bat". Python apparently requires the 8.1 Windows SDK, and only the Visual Studio 2017 version of "vcvarsall.bat" supports that. So, we call the 2017 version, but pass -vcvars_ver=12.0 to set for 2013.
SET MSSdk=1
SET DISTUTILS_USE_SDK=1
call "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat" amd64 8.1 -vcvars_ver=12.0
Then, you can run your:
python35.exe setup.py build
First of all, I know this is a common error, but I followed all the instructions posted here and in this tutorial but I think the answers are outdated (most of them are from 2010, 2011 and I'm running Windows 10).
I'm using:
Python 2.7 (32 bits)
wxPython 3.0.2
pymssql 2.1.1
Windows 10
The thing is when I install Microsoft Visual C++ Redistributable 2008, it doesn't appear in the folder C:\\Program Files\\Microsoft Visual Studio 9.0\ but it appears installed. If I ignore the dll, when I try to open the file, it stays MSVCR90.dll is missing...
Does anyone have any clue or have done it in Windows 10?
I dont know for Windows 10, but (with w7) I found them at : C:/Windows/winsxs/x86_microsoft.vc90(...)/
on the wxPython wiki is some information I and other put together. Not updated to Py2.7 but the same approach works, you just need to get the correct dll's.
http://wiki.wxpython.org/Deployment
http://wiki.wxpython.org/py2exe-python26
I', trying to compile a Python modules on Windows 7 ( Python 3.3 ) and getting the error: Unable to find vcvarsall.bat which i read around is related to not having Visual Studio 2008 installed. Bu i have visual studio 2008 installed AND it's in the path, any ideas?
EDIT - i also checked How do I point easy_install to vcvarsall.bat? but no effects, i tried setting the variable but it's ignored.
EDIT 2 - I've found out by looking at the core that it's now looking for VS100COMNTOOLS instead of VS90COMNTOOLS is the VS studio version different?
Python 3.3 on Windows is built with VS2010, which doesn't match your VS2008. Previous versions of Python did indeed use VS2008.
You'll need to get hold of VS2010.