jbardin / scp.py

scp module for paramiko
Other
529 stars 139 forks source link

ImportError: cannot import name 'SCPClient' #145

Closed zzj0402 closed 3 years ago

zzj0402 commented 3 years ago

docker image python:3.6 with scp and paramiko Run:

from paramiko import SSHClient
from scp import SCPClient

ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect('example.com')

# SCPCLient takes a paramiko transport as an argument
scp = SCPClient(ssh.get_transport())

scp.put('test.txt', 'test2.txt')
scp.get('test2.txt')

# Uploading the 'test' directory with its content in the
# '/home/user/dump' remote directory
scp.put('test', recursive=True, remote_path='/home/user/dump')

scp.close()
Traceback (most recent call last):
  File "scp.py", line 2, in <module>
    from scp import SCPClient
  File "/workspace/scp.py", line 2, in <module>
    from scp import SCPClient
ImportError: cannot import name 'SCPClient'
zzj0402 commented 3 years ago

On Windows 10 with python 3.8.5:

from scp import SCPClient
ImportError: cannot import name 'SCPClient' from partially initialized module 'scp' (most likely due to a circular import) (d:\lz78\scp.py)
remram44 commented 3 years ago

Don't call your script scp.py

rajatnair05 commented 2 weeks ago

did you get any solution for this problem.

remram44 commented 2 weeks ago

Yes, it's the last answer with 15 thumbs up. Don't revive old issues with no new information like this.