更新时间:2023-09-20 18:51:52
简短版:你正在混合Ubuntu的Python打包版本( / usr / bin / python
)以及本地构建和安装的版本( / usr / local / bin / python
)。
Short version: You're mixing Ubuntu's packaged version of Python (/usr/bin/python
) and a locally built and installed version (/usr/local/bin/python
).
长版:
apt-get install python -paramiko
将Ubuntu的官方Paramiko软件包安装到 /usr/lib/python2.7/dist-p ackages
。 pip
版本,安装到 /usr/local/lib/python2.7/dist-packages
。 (请参阅此处。) /usr/local/lib/python2.7
而不是 /usr/lib/python2.7
,并且因为它没有Debian / Ubuntu自定义,所以它不会检查使用 dist-packages
。apt-get install python-paramiko
to install Ubuntu's official Paramiko package to /usr/lib/python2.7/dist-packages
.pip
, which installs to /usr/local/lib/python2.7/dist-packages
. (See here.)/usr/local/lib/python2.7
instead of /usr/lib/python2.7
, and because it doesn't have Debian/Ubuntu customizations, it doesn't check use dist-packages
.解决方案:您应该能够将 /usr/local/lib/python2.7/dist-packages
添加到您的 / usr / local / bin / python
的 sys.path
,但是因为你使用的是Ubuntu,所以最容易让Ubuntu为你做的工作:
Solution: You should be able to add /usr/local/lib/python2.7/dist-packages
to your /usr/local/bin/python
's sys.path
, but since you're using Ubuntu, it's easiest to let Ubuntu do the work for you:
apt-get
而不是 pip
)。apt-get
instead of pip
).我会这么做的r卸载本地版本的Python并删除 /usr/local/lib/python2.7
,以确保不会发生进一步的不匹配。如果您不想那么激烈,那么您可以在 / usr / local / bin之前编辑$ PATH以放入
默认情况下运行Python的系统版本。 / usr / bin
I'd go so far as to uninstall the local version of Python and delete /usr/local/lib/python2.7
, to ensure that no further mismatches occur. If you don't want to be that drastic, then you can edit your $PATH to put /usr/bin
before /usr/local/bin
to run the system version of Python by default.