简体   繁体   中英

wfastcgi fails import cx_Oracle, but `python -c “import cx_Oracle” succeeds

I have IIS setup with fastCGI, serving a flask app. So far so good. Next I whish to add some database connectivity, so I add the line import cx_Oracle to my app. Now this error is thrown:

Error occurred while reading WSGI handler: 
Traceback (most recent call last): 
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 791, in main 
    env, handler = read_wsgi_handler(response.physical_path) 
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler 
    handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) 
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 616, in get_wsgi_handler 
    raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb)) 
ValueError: "Bloomberg_server.app" could not be imported: 

Traceback (most recent call last): 
File "D:\Anaconda2\lib\site-packages\wfastcgi.py", line 600, in get_wsgi_handler 
    handler = __import__(module_name, fromlist=[name_list[0][0]]) 
File "D:\website\init__.py", line 6, in  import cx_Oracle 
    ImportError: DLL load failed: The specified module could not be found. StdOut: StdErr: 

As the title suggests I fail to reproduce the issue in a controlled environment. The very same import statement works fine in the conda environment and moreover, I can run the Flask debug server just fine with pages that rely on a database connection.

I am at loss. Who has a clue what's going on here? The path/oracle_home variables are pointing to the instant client and I have only one python environment installed.

I am too embarrased to admit how long this has taken me, but I've found the answer. FastCGI's core business is keeping subprocesses alive so that subsequent calls to the server do not require booting a Python environment. In other words, after installing a python package it is advised to reboot. I solved my first question on SO by rebooting..

The answer to this question got me thinking in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM