【问题标题】:Python-ping module not found after installation安装后找不到 Python-ping 模块
【发布时间】:2015-02-07 19:55:14
【问题描述】:

我尝试使用pip 安装python-ping,但我得到了:

Downloading/unpacking python-ping
  Could not find a version that satisfies the requirement python-ping (from versions: 2011.10.12.11fc9f7, 2011.10.12.1d8e600, 2011.10.13.12050a5, 2011.10.17.376a019)
Cleaning up...
No distributions matching the version for python-ping
Storing debug log for failure in /root/.pip/pip.log

所以我用pip install --pre python-ping安装了它,安装输出:

Downloading/unpacking python-ping
  Downloading python-ping-2011.10.17.376a019.tar.gz
  Running setup.py (path:/tmp/pip-build-8QnXqD/python-ping/setup.py) egg_info for package python-ping

    warning: no previously-included files matching '*.pyc' found under directory '*'
    warning: no previously-included files matching '*.pyo' found under directory '*'
Installing collected packages: python-ping
  Running setup.py install for python-ping
    changing mode of build/scripts-2.7/ping.py from 644 to 755

    warning: no previously-included files matching '*.pyc' found under directory '*'
    warning: no previously-included files matching '*.pyo' found under directory '*'
    changing mode of /usr/bin/ping.py to 755
Successfully installed python-ping
Cleaning up...

尽管有警告,但我认为它是成功的。

然后我尝试导入 ping 模块进行测试,复制粘贴 first answer here,但我得到了:

ImportError: No module named ping

我第一次使用pip 安装模块时遇到任何问题。我该如何解决这个问题?

【问题讨论】:

  • 你总是可以使用子进程来 ping 并忘记使用库
  • @PadraicCunningham 它不会是跨平台的。

标签: python module pip ping


【解决方案1】:

根据python-ping包的setup.py,它不安装模块,而是安装脚本(应该安装在你的python脚本文件夹中)。您应该直接调用脚本,例如:ping.py www.google.com。如果这不起作用,请确保您的路径设置为包含系统上的 python 脚本文件夹。

如果您更喜欢模块解决方案,请查看 pypi 上的 pinghttps://pypi.python.org/pypi/ping/0.2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-19
    • 2013-07-10
    • 2016-07-23
    • 2021-03-05
    • 2019-08-04
    相关资源
    最近更新 更多