Python 导入错误:没有名为“paramiko”的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28173520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 02:51:43  来源:igfitidea点击:

ImportError: No module named 'paramiko'

pythonpython-3.xparamiko

提问by jeff_h

I have done through the other questions online here, and I feel that mine is different enough to warrant a new question.

我已经完成了这里在线的其他问题,我觉得我的问题足够不同,值得提出一个新问题。

So I have a Centos 6 box, which is running a small website for me, acts as an office git server and I am trying to configure Python3on it.

所以我有一个Centos 6 box,它正在为我运行一个小型网站,充当办公室 git 服务器,我正在尝试对其进行配置Python3

So I followed the following these stepsto set up python3on the server. However it seems that I cannot import paramiko into my script.

所以我按照以下这些步骤python3在服务器上进行设置。但是,似乎我无法将 paramiko 导入到我的脚本中。

I downloaded the paramiko rpm however I get this message:

我下载了 paramiko rpm,但收到此消息:

When I try to import paramiko I get:

当我尝试导入 paramiko 时,我得到:

[root@GIT Python-3.4.2]# rpm -ivh /usr/lib/Python-3.4.2/Modules/python-paramiko-1.7.5-2.1.el6.noarch.rpm
Preparing...                ########################################### [100%]
package python-paramiko-1.7.5-2.1.el6.noarch is already installed

When I run python3 directly:

当我直接运行python3时:

[root@GIT inserv_health_check]# python3
Python 3.4.2 (default, Jan 21 2015, 06:28:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'paramiko'
>>>

I am sure there is a simple solution to this problem perhaps the path is wrong, or I should have put a symbolic link in somewhere. Any help would be appreciated :)

我确信这个问题有一个简单的解决方案,也许路径是错误的,或者我应该在某处放置一个符号链接。任何帮助,将不胜感激 :)

Before anyone asks, which python output:

在有人问之前,哪个 python 输出:

[root@GIT Python-3.4.2]# which python
/usr/bin/python
[root@GIT Python-3.4.2]# which pytho~n3
/usr/bin/which: no pytho~n3 in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root@GIT Python-3.4.2]# which python3
/usr/local/bin/python3

Thanks

谢谢

采纳答案by Kostas Livieratos

You need to do pip install paramikoso that python sees that module. If you work on a virtual environment, you need to workon <env_name>first and then pip installthe desired module.

您需要这样做,pip install paramiko以便 python 看到该模块。如果您在虚拟环境中工作,则需要workon <env_name>首先创建pip install所需的模块。