鱼C论坛

 找回密码
 立即注册
查看: 3247|回复: 9

[已解决]关于Python3使用 CentOS7使用SNMP工具的问题

[复制链接]
发表于 2019-8-29 10:24:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
各位鱼油
          我想问个问题,我在CentOS7安装完Python3后,想使用netsnmp这个工具,但那是我经过各种坎坷安装成功以后,发现Python2没有问题,Python3无法使用,请问各位鱼油,有没有类似的经验,求教。
实验目的:是为了使用Python做设备巡检,如路由器,交换机,服务器等等。

截图
[root@localhost ~]# python3
Python 3.7.3 (default, Jun 21 2019, 17:08:14)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netsnmp'
>>>
[root@localhost ~]# python
Python 2.7.5 (default, Jun 20 2019, 20:27:34)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
>>>
最佳答案
2019-8-29 13:48:25
LuckFly 发表于 2019-8-29 11:28
还是不行,貌似没有找到3的版本。
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp

pip3 install python3-netsnmp

项目地址
https://pypi.org/project/python3-netsnmp/
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-8-29 10:26:10 | 显示全部楼层
pip3 install xxxx
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-29 10:28:20 | 显示全部楼层
因为你装到python2里面去了,要装到python3里面去,可以使用pip3 install netsnmp
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-29 10:37:45 | 显示全部楼层
pip3 install ---
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-8-29 10:41:17 | 显示全部楼层

尝试使用安装,提示我没有找到相关的版本
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp
  Could not find a version that satisfies the requirement netsnmp (from versions: )
No matching distribution found for netsnmp
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

更新pip发现是2版本
[root@localhost ~]# pip install --upgrade pip
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/de ... s/#python-2-support
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages (19.2.3)
尝试更新3版本发现成功
[root@localhost ~]# pip3 install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/p ... y2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.3

再次使用安装发现报错了,还是没有找到版本。
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp
  ERROR: Could not find a version that satisfies the requirement netsnmp (from versions: none)
ERROR: No matching distribution found for netsnmp
[root@localhost ~]# python3
Python 3.7.3 (default, Jun 21 2019, 17:08:14)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netsnmp'
>>>


我不是特别懂系统,基本全靠bing,请鱼油帮助。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-8-29 10:42:01 | 显示全部楼层
空青 发表于 2019-8-29 10:28
因为你装到python2里面去了,要装到python3里面去,可以使用pip3 install netsnmp

尝试使用安装,提示我没有找到相关的版本
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp
  Could not find a version that satisfies the requirement netsnmp (from versions: )
No matching distribution found for netsnmp
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

更新pip发现是2版本
[root@localhost ~]# pip install --upgrade pip
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/de ... s/#python-2-support
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages (19.2.3)
尝试更新3版本发现成功
[root@localhost ~]# pip3 install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/p ... y2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.3

再次使用安装发现报错了,还是没有找到版本。
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp
  ERROR: Could not find a version that satisfies the requirement netsnmp (from versions: none)
ERROR: No matching distribution found for netsnmp
[root@localhost ~]# python3
Python 3.7.3 (default, Jun 21 2019, 17:08:14)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netsnmp'
>>>


我不是特别懂系统,基本全靠bing,请各位鱼油帮助。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-8-29 11:28:30 | 显示全部楼层
还是不行,貌似没有找到3的版本。
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp
  Could not find a version that satisfies the requirement netsnmp (from versions: )
No matching distribution found for netsnmp
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@localhost ~]# pip install --upgrade pip
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/de ... s/#python-2-support
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages (19.2.3)
[root@localhost ~]# pip3 install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/p ... y2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-19.2.3
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp
  ERROR: Could not find a version that satisfies the requirement netsnmp (from versions: none)
ERROR: No matching distribution found for netsnmp
[root@localhost ~]# python3
Python 3.7.3 (default, Jun 21 2019, 17:08:14)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netsnmp'
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-29 13:48:25 | 显示全部楼层    本楼为最佳答案   
LuckFly 发表于 2019-8-29 11:28
还是不行,貌似没有找到3的版本。
[root@localhost ~]# pip3 install netsnmp
Collecting netsnmp

pip3 install python3-netsnmp

项目地址
https://pypi.org/project/python3-netsnmp/
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-8-29 13:54:46 | 显示全部楼层
空青 发表于 2019-8-29 13:48
pip3 install python3-netsnmp

项目地址

这难道是我版本下的有问题么,是否和centos7有关系?
[root@localhost python]# pip3 install python3-netsnmp
Collecting python3-netsnmp
  Downloading https://files.pythonhosted.org/p ... etsnmp-1.1a1.tar.gz
Installing collected packages: python3-netsnmp
  Running setup.py install for python3-netsnmp ... done
Successfully installed python3-netsnmp-1.1a1
[root@localhost python]# python3
Python 3.7.3 (default, Jun 21 2019, 17:08:14)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netsnmp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/net-snmp-5.7.3/python/netsnmp/__init__.py", line 1, in <module>
    from client import *
ModuleNotFoundError: No module named 'client'
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-8-29 14:24:05 | 显示全部楼层
问题已经解决,感谢各位鱼油支持。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-4 08:44

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表