简体   繁体   中英

IIS CGI could not locate my python modules

I am trying to run my python scripts on my IIS website using CGI and I am having trouble with importing. When run on its own, the python scripts finds the mysql.connector<\/code> module installed in my os perfectly fine, but when I try to run it on the website, it gives a Bad Gateway (502.2) error with the stacktrace stating ModuleNotFoundError: No module named 'mysql.connector'<\/code> . I'm assuming CGI cannot find the module in my OS, how can I let it find the module? Do I have to specify my modules folder somewhere in the IIS like a PATH variable?


The specified CGI application misbehaved by not returning a complete set of HTTP headers.<\/strong> The headers it did return are "Traceback (most recent call last): File "C:\\Users\\pedro\\OneDrive\\Documents\\adet\\ind.py", line 2, in import python_mysql File "C:\\Users\\pedro\\OneDrive\\Documents\\adet\\python_mysql.py", line 1, in import mysql.connector ModuleNotFoundError: No module named 'mysql.connector' ".<\/strong>

As a workaround, I simply copied and pasted all of my modules in my modules folder to my website's folder. I guessed that since my personal imports were working that it should also work if I added the other modules to the same folder and lo, it did. I hope there's a cleaner way to solve this, but for now I'll choose this as a solution.

"

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