在 mac 上设置 XAMPP 到 运行 python 脚本
Setting up XAMPP to run python script on mac
我用谷歌搜索并尝试了所有方法,但我不能 运行 我的 test.py 在 apache 上。
我已将 httpd.conf 文件更新为 AddHandler .py
URL我用的是http://localhost/cgi-bin/test.py
test.py
#!/Library/Frameworks/Python.framework/Versions/3.4 python
print("Content-Type: text/html");
print();
print("<html><head></head><body>");
print ("Hello");
print("</body></html>");
我不确定 shebang 行是否正确,但那是我安装的地方 python。
当我在浏览器中打开此文件时出现此错误
Error message:
End of script output before headers: test.py
请提出建议,如有帮助将不胜感激。
您确定 python 安装路径正确吗?默认情况下应该是
#!/Python27/python
一来二去,在terminal里做了这个
which python
我得到了我的 exe 的路径
#!/Library/Frameworks/anaconda/bin/python
我使用了这个并且我的脚本成功了,希望这对其他人也有帮助。
我用谷歌搜索并尝试了所有方法,但我不能 运行 我的 test.py 在 apache 上。 我已将 httpd.conf 文件更新为 AddHandler .py
URL我用的是http://localhost/cgi-bin/test.py
test.py
#!/Library/Frameworks/Python.framework/Versions/3.4 python
print("Content-Type: text/html");
print();
print("<html><head></head><body>");
print ("Hello");
print("</body></html>");
我不确定 shebang 行是否正确,但那是我安装的地方 python。
当我在浏览器中打开此文件时出现此错误
Error message:
End of script output before headers: test.py
请提出建议,如有帮助将不胜感激。
您确定 python 安装路径正确吗?默认情况下应该是
#!/Python27/python
一来二去,在terminal里做了这个
which python
我得到了我的 exe 的路径
#!/Library/Frameworks/anaconda/bin/python
我使用了这个并且我的脚本成功了,希望这对其他人也有帮助。