简体   繁体   中英

ValueError: invalid literal for int() with base 10: '--cgi' when using python3 -m http.server --cgi 8000

When i run python3 -m http.server --cgi 8000 It says:

Traceback (most recent call last):
  File "/usr/lib/python3.2/runpy.py", line 160, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python3.2/runpy.py", line 73, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.2/http/server.py", line 1187, in <module>
    test(HandlerClass=SimpleHTTPRequestHandler)
  File "/usr/lib/python3.2/http/server.py", line 1169, in test
    port = int(sys.argv[1])
ValueError: invalid literal for int() with base 10: '--cgi'

It looks like the --cgi flag was only added in python 3.3. You're using python 3.2, which expects the only argument to be a port number.

The fix seems to be to upgrade to python 3.3 or not use --cgi.

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