I am a newbie to Stack Overflow (first post), but really see the use of this website.
I'm stumped. We are trying to setup IIS 7.0 to run with WinPython 2.7 on a Windows 7 machine.
I am an IIS newb, but veteran Python user. IIS 7 can NOT find a library, which python finds, and executes, perfectly when ran on it's own. When executed via IIS, the script fails with a traceback, and IIS returns the 502.2.
I found this thread http://forums.iis.net/p/1209465/2073173.aspx?HTTP+Error+502+2+Bad+Gateway+Frustrations but the advised solution is simply another troubleshooting suggestion.
I found IIS's description (http://support.microsoft.com/kb/942057) of the error helpful, but futile.
I found Python's start-up options/parameters helpful (http://docs.python.org/2/using/cmdline.html), but futile.
I found IIS's advice for configuring Python helpful (http://support.microsoft.com/kb/276494, but (questionably?) incomplete.
This thread on manually defining an alternate bin folder (http://forums.asp.net/t/1303052.aspx?Tell+IIS+to+load+dll+from+another+directory+not+Bin+web+config+) might be where my solution lies, but I don't think it is because of the fact that this all worked on 2.6 without doing that to IIS.
IIS seems to allow python to import any module that is just a python script. As soon as it gets to a *.pyd (basically just python's version of a dll file) file, it screams. I'm no pro when it comes to DLLs and windows environments, but wouldn't IIS have to have paths to a bin folder of some kind? Do I have to manually edit them, as discussed in the last link above?
ACTUAL ERROR Details below for DLL failed Load:
The Error :
" HTTP Error 502.2 - Bad Gateway The specified CGI application
misbehaved by not returning a complete set of HTTP headers. The
headers it did return are "Traceback (most recent call last): File
"\estorage.equitable.int\riskmgmt\Quants\web\LinksPage.py", line 2,
in import pyweb File
"\estorage.equitable.int\riskmgmt\Quants\Common2014\Python\pyweb__init__.py",
line 5, in from core import * File
"\estorage.equitable.int\riskmgmt\Quants\Common2014\Python\pyweb\core.py",
line 2, in from pylib import pgdb File
"\estorage.equitable.int\riskmgmt\Quants\Common2014\Python\pylib\pgdb.py",
line 8, in from scikits import timeseries as ts File
"C:\WinPython-32bit-2.7.6.2-20140401\python-2.7.6\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries__init__.py",
line 13, in import const File
"C:\WinPython-32bit-2.7.6.2-20140401\python-2.7.6\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py",
line 79, in from cseries import freq_constants ImportError:
DLL load failed: The specified module could not be found. ".
I'm confident that the python environment is configured properly, as the script runs from the same executable (python.exe) via a command line. I'm thinking that I don't have IIS configured properly, for the new Python 2.7 install. The same script worked yesterday, on IIS and python 2.6. But during our upgrade from 2.6 to 2.7, a bunch of PATH and PYTHONPATH parameters all changed, plus we went from ActivePython to WinPython. WinPython is "registered" on the machine.
What I've tried
confirming python's sys.path is as expected at run-time in both IIS and command line - it is.
using the module from python command line.
recompiling the failing module using two different compilers (ming32 and VS2008).
putting duplicates of my new 2.7 modules in the old python26 folder.
pulling out lots of hair and other hacky stuff.
My next step, is to post this same message on a python forum. If anybody can advise on a good one for python-IIS related challenges, that would be appreciated.
Please help! Thanks in advance.
I got this 502.2 error when doing a clean installation of PHP 5.5 in Windows Server 2012 R2 with IIS 8.5.
It turns out PHP is a Visual C++ application which needs the library MSVCR110.dll in order to run properly. My computer does not have Visual Studio 2012 installed and thus it does not have this file. I got my problem solved by installing the Visual C++ Redistributable Packages https://www.microsoft.com/en-us/download/details.aspx?id=30679#
(Note: jc77 is my associate, and I'm actually the OP, as this was an x-post from IIS forums.)
We solved the problem.
tl,dr; portable python + sloppy/rookie compiling = strange behaviour + frustrations.
Bottom line, compile properly. For scikits.timeseries, using ming32 everything will walk, talk, and sound like it works in Spyder.exe, but not in python.exe. You have to use VS2008, if you want it to work in both.
More Info:
Winpython (as well as others) presents itself as identical to any other python installations, if you "register" the installation. It works great, 99% of the time. We learned the hard way, that "Winpython Interpreter.exe" and "python.exe" provided in the install are in fact different. Can't explain why, but the two executables gave different behavior. We were doing all our testing in Spyder, which must use "winpython interpreter.exe". The module which IIS couldn't find, would import and run no problem in Spyder. Then, in IIS, using python.exe, the module wouldn't import. We were operating on the assumption that the IDE would use python.exe, and that the stack was identical. As, 99% of the time, they appear to be. The way we were compiling scikits worked in winpython interpreter.exe. We were making a rookie mistake when compiling scikits, but it went un-noticed because it was working fine in our IDE (Spyder).
I'm adding these keywords for others : Anybody else who receives errors like this is likely using a portable python installation AND not compiling something properly. Winpython, Portable Python, eGenix, [and possibly?] Active State and Enthought Canopy.
While trying to configure CGI to run Perl in Windows 8.1, I had HTTP Error 502.2, but then I read loste's post and solved the problem. I had previously installed both Perl64 and Strawberry Perl. Although the IIS EventHandler pointed to only the Perl64 directory, both directories appeared in my Windows PATH variable. I prefer Strawberry Perl, so I changed the EventHandler to point to the Strawberry Perl directory and deleted the paths to Perl64 from the Windows PATH variable to solve the error.
Try this
print("Content-Type: text/html\n")
print("Hello Python World!")
You must specify the type of document
I installed python 2.6 and MySQL-python-1.2.2.win32-py2.6 and created a new project using the command django-admin.py startproject mysite and it successfully created the project and I could run it.But when I edit mysite/settings.py file to use MySQLdb and run it again,it says
Validating models...
Unhandled exception in thread started by bound method Command.inner_run of dja
ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x02BFCB
raise ImproperlyConfigured(Error loading MySQLdb module:)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: DLL l
oad failed: The specified module could not be found.
I tried searching all net and couldn't identify the problem.Is it to do with setting some environment variables? Can anyone please help me about this?
If you fire up regular python and try
>>> import MySQLdb
and then fire up the django shell
> python manage.py shell
>>> import MySQLdb
and get the same error, I would presume that you have the wrong SQL package for your system - this is often a 32bit vs 64bit issue.
Dig out the actual SQL dll (called _mysql.pyd and see if you can import that directly into pyton (go to the directory containing the dll, fire up python and import _mysql). This should help speed up the diagnosis.
Alternatively, I've always found Bitnami's django stack to be the least painful way to install and manage my Windows django stack. It will set up and manage Apache HTTP Server, MySQL, Python, SQLite, PostgreSQL, Django all in one go.
I'm trying to compile the _ssl module on Windows for Python 2.6 using the MSVC compiler, because the Python runtime embedded into the host application is built with this compiler and of this version. The runtime does not come with native ssl-support on Windows however, not because it is not supported, but because (among an official statement) licenses have not yet been checked to be compatible with the closed-source application.
I've downloaded the CPython 2.6.8 source from the Python homepage and extracted _ssl.c and socketmodule.h (required include by the ssl module source) into a separate folder. I've also downloaded the openssl-for-windows win32 builds in order to linke it with the ssl module source.
My build-commands are the following:
cl /I"C:\path\to\host\python\runtime\include" /I"include/" _ssl.c /Fo"_ssl.obj" /c
link _ssl.obj /DLL "C:\path\to\host\python\runtime\libs\python26.lib" lib/libeay32.lib lib/ssleay32.lib Ws2_32.lib /OUT:_ssl.pyd
libeay32.lib and ssleay32.lib are from the openssl-for-windows distribution. The module compiles fine and outputs an 88KB shared library.
Problem
When I start the host application and run a command invoking the Python runtime running code importing and using the recently compiled _ssl module, the application crashes. The host application has its own kind of exception handler writing a bugreport when crashing.
Exception
{
ExceptionNumber = 0xC0000005
ExceptionText = "ACCESS_VIOLATION"
Address = 0x01A27058
Thread = 4776
Last_Error = 0x00000000
}
The call-stack at the point of the exception does not end in any Python related procedures. I assume that something incorrect happened before that triggers the error at this place.
Weirdness
When I run the application from the Win32 Debugger (WinDbg), this error does not happen and everything runs fine.
Question
What am I doing wrong with compiling the _ssl module, or what could trigger this exception?
Additional Information
The embedded Python runtime is the following: 2.6.4 (r264:75706, Mar 6 2012, 02:32:04) [MSC v.1600 32 bit (Intel)]
The crash finally was due to a bug in the host application. This bug could however only occure, when data was fetched from the web, which was only possible with the ssl module.
While it was stated that it's not the best idea to host a reviewboard for mercurial on windows evironment I stil gave it a try. So far I have not succeeded. And thus I am in search of help.
I am running Windows 7 x64 and have followed the official Installing on Windows guide.
Here I had no problems, problem occured when I chose wsgi. Now I am using Apache 2.2 32bit, python 2.5.4 32 bit and I have downloaded an apache wsgi module from: http://code.google.com/p/modwsgi/wiki/InstallationOnWindows
Strangly enough they don't have module for this particular combo (Apache 2.2|python 2.5) so I grabbed the closest thing: mod_wsgi-win32-ap22py26-3.3.so - Apache 2.2 / Python 2.6
Still I did not consider win32 would be of any problems for win64 huh ?
Well after I have told Apache2.2 in it's httpd.conf to "LoadModule wsgi_module modules/mod_wsgi.so" that I have put in modules folder, here is what it told me:
httpd.exe: Syntax error on line 129 of G:/tools/Apache2/conf/httpd.conf:
Cannot load G:/tools/Apache2/modules/mod_wsgi.so into server: %1 is not
a valid Win32 application.
Is this cause I use python 2.5 not 2.6 AND/OR windows 7 64 ? And if it's has any relation to python version - I couldn't find wsgi mod for 2.5 at least not downloadable version, only sources that need to be compiled and then some.
Has anyone faced similar problems and could advice or give hint how to load those that wsgi module ?
I'm pretty sure that mod_wsgi has to be compiled against the correct Python version, so you can't use mod_wsgi-win32-ap22py26-3.3.so with 2.5.4.
(BTW, not sure why you're still using 2.5 anyway?)
I recently upgraded my Google App Engine launcher on my Mac, running OSX 10.5.8, and afterwards my projects that work with images stopped working locally.
It seems to be the same problem that I had when first using GAE locally to work with images, before I installed PIL. Here is the error I get:
SystemError: Parent module 'PIL' not loaded
I have PIL installed. When I run python normally, I can access it and work with it as expected. I also checked to ensure that dev_appserver.py was running the same version of Python. If I open the interpreter and type sys.version I get this back:
2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)]
This is identical to what I get when I display the sys.version from my projects running through dev_appserver. Any thoughts on why dev_appserver can't find the PIL module? I have been banging my head against this for a bit.
Thank you!
You may be suffering from the problems I was explaining here, specifically, I think...:
You need to find another way to extend Python sys.path's
appropriately. The simplest way is to
make a file named PIL.pth with a
single-line content:
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages
and place that PIL.pth in any of the
directories that all Python processes
see; in my case, I used
/Library/Python/2.5/site-packages/ --
but that directory is not available in
a pristine installation of Mac OS X
10.5 so you may have to use some other directory.