SSHTunnel not installed correctly?

↘锁芯ラ 提交于 2021-01-28 23:50:15

问题


I'm using anaconda python 3.5.2 in PyCharm using windows 10.

I'm pretty new to python and a complete noob to PyCharm!

I just want to use SSHtunnel.

I have intalled the package and it shown in the project interpreter page:

However when I try to run the code which I cut and pasted from example 1 here 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()

I get the following error:

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

How can I sort this out?


回答1:


sshtunnel for python and sshtunnel Anaconda-python are different modules.

To install sshtunnel for Anaconda; you need to use the Anaconda repository. use below pip command; Hope this helps:

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

More Description Here




回答2:


I think your name of file is sshtunnel.py




回答3:


Just run the command below:

pip install sshtunnel



回答4:


i face this problem on window 10 and fix it buy this line

easy_install sshtunnel


来源:https://stackoverflow.com/questions/40471364/sshtunnel-not-installed-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!