SSHTunnel没有正确安装?

问题描述 投票:1回答:2

我正在Windows 10的PyCharm中使用anaconda python 3.5.2。

我对python很陌生,对PyCharm来说是一个全新菜鸟!

我只想使用SSHtunnel。

我已经安装了程序包,它显示在项目解释器页面中:

enter image description here

但是,当我尝试运行从示例1此处https://github.com/pahaz/sshtunnel剪切并粘贴的代码时:

from sshtunnel import SSHTunnelForwarder

server = SSHTunnelForwarder(
'pahaz.urfuclub.ru',
ssh_username="pahaz",
ssh_password="secret",
remote_bind_address=('127.0.0.1', 8080)
)

server.start()

print(server.local_bind_port)  # show assigned local port
# work with `SECRET SERVICE` through `server.local_bind_port`.

server.stop()

我收到以下错误:

C:\Users\HP\Anaconda3\python.exe C:/Users/HP/PycharmProjects/SSH_Downloader/SSH_Downloader
Traceback (most recent call last):
  File "C:/Users/HP/PycharmProjects/SSH_Downloader/SSH_Downloader", line 1, in <module>
    from sshtunnel import SSHTunnelForwarder
ImportError: cannot import name 'SSHTunnelForwarder'

Process finished with exit code 1

我该如何解决?

python-3.x pycharm ssh-tunnel
2个回答
0
投票

[sshtunnel for python和sshtunnel Anaconda-python是不同的模块。

要为Anaconda安装sshtunnel;您需要使用Anaconda存储库。使用下面的pip命令;希望这会有所帮助:

pip install -i https://pypi.anaconda.org/pypi/simple sshtunnel

更多说明Here


0
投票

我认为您的文件名为sshtunnel.py

© www.soinside.com 2019 - 2024. All rights reserved.