首页 > 解决方案 > 错误:命令出错,退出状态为 1:python setup.py egg_info 检查日志以获取完整的命令输出。尝试安装 ping 模块时

问题描述

sh: ping: command not found

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Collecting ping
  Using cached ping-0.2.tar.gz (10 kB)
    ERROR: Command errored out with exit status 1:
     command: /Library/Developer/CommandLineTools/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/q3/1cj5lfqn0ds0plbtnv9tqr4r0000gn/T/pip-install-4fgeslm7/ping/setup.py'"'"'; __file__='"'"'/private/var/folders/q3/1cj5lfqn0ds0plbtnv9tqr4r0000gn/T/pip-install-4fgeslm7/ping/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/q3/1cj5lfqn0ds0plbtnv9tqr4r0000gn/T/pip-pip-egg-info-p_o79ek6
         cwd: /private/var/folders/q3/1cj5lfqn0ds0plbtnv9tqr4r0000gn/T/pip-install-4fgeslm7/ping/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/q3/1cj5lfqn0ds0plbtnv9tqr4r0000gn/T/pip-install-4fgeslm7/ping/setup.py", line 23, in <module>
        from ping import __version__
      File "/private/var/folders/q3/1cj5lfqn0ds0plbtnv9tqr4r0000gn/T/pip-install-4fgeslm7/ping/ping.py", line 196
        except socket.error, (errno, msg):
                           ^
    SyntaxError: invalid syntax

我尝试了很多解决方案,但都没有奏效,请帮助我

标签: pythonmoduleping

解决方案


此软件包仅适用于 Python 2。它不再被维护(最近一次提交是在 2010 年),所以它被移植到 Python 3 的希望很小。

您可以改用pythonping包:

from pythonping import ping

ping('127.0.0.1', verbose=True)

推荐阅读