[英]Running a simple local HTTP server using Python 3.x
我正在關注這個幫助頁面: https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server
我正在運行 Windows 10 和 Python 3.7.8。 我創建了一個需要測試環境的文件夾。 然后我將命令提示符中的目錄更改為該文件夾並運行命令以啟動服務器。 C:\Users\jpilbeam\TestEnvironment>python3 -m http.server
但這不起作用,替代端口 7800 也沒有: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
我知道我的機器上有幾份 Python 3.x。 從終端我只找到一個使用這個: python -c "import sys; print('\n'.join(sys.path))"
打印: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64
根據該幫助文檔,我無法設置服務器。
確保將 python 添加到您的環境路徑中。 如果您不確定如何執行此操作,可以按照此操作或卸載並重新安裝 Python 並確保勾選添加到環境路徑的框。
嘗試執行python --version
如果出現,您的環境路徑已設置。
嘗試使用python -m http.server
代替。
感謝 FluxedScript,我完成了以下工作流程以使其工作:(1)Windows 開始菜單-> 輸入環境變量(2)在系統屬性菜單中我單擊環境變量(3)在環境的系統變量 window變量菜單我突出顯示路徑並單擊編輯 (4) 我單擊新建然后輸入: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64
---> 然后在所有菜單上單擊確定
回到命令提示符:
C:\Users\jpilbeam>cd C:\Users\jpilbeam\TestEnvironment
C:\Users\jpilbeam\TestEnvironment>py -V
Python 3.7.8
C:\Users\jpilbeam\TestEnvironment>python3 -m http.server ###this did not work!
C:\Users\jpilbeam\TestEnvironment>python -m http.server ###this did work!
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.