New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'module' object has no attribute 'c_ssize_t' #802

Closed
X286 opened this Issue Aug 24, 2016 · 12 comments

Comments

Projects
None yet
3 participants
@X286

X286 commented Aug 24, 2016

import paramiko

ip=
port=22
username='username'
password='passw'

cmd='dir'

ssh=paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
ssh.connect(ip,port, username,password, look_for_keys=False)

stdin,stdout,stderr=ssh.exec_command(cmd)
outlines=stdout.readlines()
resp=''.join(outlines)
print(resp)

gives me error:

C:\Python27\lib\site-packages\paramiko\client.py:664: UserWarning: Unknown ssh-rsa host key for <host>: <key>
  (key.get_name(), hostname, hexlify(key.get_fingerprint())))
Traceback (most recent call last):
  File "sshclient.py", line 13, in <module>
    ssh.connect(ip,port, username,password)
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 380, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 536, in _auth
    self._agent = Agent()
  File "C:\Python27\lib\site-packages\paramiko\agent.py", line 355, in __init__
    from . import win_pageant
  File "C:\Python27\lib\site-packages\paramiko\win_pageant.py", line 36, in <module>
    from . import _winapi
  File "C:\Python27\lib\site-packages\paramiko\_winapi.py", line 92, in <module>
    GlobalAlloc.argtypes = ctypes.wintypes.UINT, ctypes.c_ssize_t
AttributeError: 'module' object has no attribute 'c_ssize_t'

OS: Win7

@bitprophet

This comment has been minimized.

Show comment
Hide comment
@bitprophet

bitprophet Aug 25, 2016

Member

This should have been fixed a while ago in #619 (Paramiko 1.15.5, 1.16.1, and up). Please comment w/ your specific paramiko version if you're on something newer than those and still seeing this. thanks!

Member

bitprophet commented Aug 25, 2016

This should have been fixed a while ago in #619 (Paramiko 1.15.5, 1.16.1, and up). Please comment w/ your specific paramiko version if you're on something newer than those and still seeing this. thanks!

@bitprophet bitprophet closed this Aug 25, 2016

@X286

This comment has been minimized.

Show comment
Hide comment
@X286

X286 Aug 26, 2016

Hello! my version 2.0.2. upgrade by using pip.
i connect to RPI (Rasbian), if it helps. on rpi installed openSSH. That's all.
Thanks for your answer.
ps Sorry, I only teach English.

X286 commented Aug 26, 2016

Hello! my version 2.0.2. upgrade by using pip.
i connect to RPI (Rasbian), if it helps. on rpi installed openSSH. That's all.
Thanks for your answer.
ps Sorry, I only teach English.

@bitprophet

This comment has been minimized.

Show comment
Hide comment
@bitprophet

bitprophet Aug 26, 2016

Member

Wonder if @jaraco sees anything I don't, here? All I can say is to make extra sure you don't have multiple Paramiko versions installed somehow (i.e. maybe you have an older one that is running instead of the 2.0.2 pip installed).

Member

bitprophet commented Aug 26, 2016

Wonder if @jaraco sees anything I don't, here? All I can say is to make extra sure you don't have multiple Paramiko versions installed somehow (i.e. maybe you have an older one that is running instead of the 2.0.2 pip installed).

@jaraco

This comment has been minimized.

Show comment
Hide comment
@jaraco

jaraco Aug 27, 2016

Contributor

@X286: The error you've reported looks like an issue with your Python installation. ctypes.c_ssize_t should be provided by the stdlib.

What do you get if you run python -c "import ctypes, sys; print(sys.version); ctypes.c_ssize_t"? If it crashes with the same error, I recommend upgrading or re-installing your Python.

Contributor

jaraco commented Aug 27, 2016

@X286: The error you've reported looks like an issue with your Python installation. ctypes.c_ssize_t should be provided by the stdlib.

What do you get if you run python -c "import ctypes, sys; print(sys.version); ctypes.c_ssize_t"? If it crashes with the same error, I recommend upgrading or re-installing your Python.

@jaraco

This comment has been minimized.

Show comment
Hide comment
@jaraco

jaraco Aug 27, 2016

Contributor

Okay. I digged a little deeper. Looking at the ctypes docs, c_ssize_t was added in Python 3.2, which means it was probably not backported to Python 2.7 until late.

More importantly, though, the GlobalAlloc API docs indicate that this parameter is meant to be a c_size_t and not c_ssize_t anyway, and since that's the only place in jaraco.windows that c_ssize_t is used, I'm guessing that's a typo and it'll work better and on more Pythons with c_size_t.

Contributor

jaraco commented Aug 27, 2016

Okay. I digged a little deeper. Looking at the ctypes docs, c_ssize_t was added in Python 3.2, which means it was probably not backported to Python 2.7 until late.

More importantly, though, the GlobalAlloc API docs indicate that this parameter is meant to be a c_size_t and not c_ssize_t anyway, and since that's the only place in jaraco.windows that c_ssize_t is used, I'm guessing that's a typo and it'll work better and on more Pythons with c_size_t.

@X286

This comment has been minimized.

Show comment
Hide comment
@X286

X286 Aug 27, 2016

@jaraco @bitprophet
Hello!
I try your solution in Monday.
On my home computer i cannot reproduce error.
Thanks for your support.

X286 commented Aug 27, 2016

@jaraco @bitprophet
Hello!
I try your solution in Monday.
On my home computer i cannot reproduce error.
Thanks for your support.

@X286

This comment has been minimized.

Show comment
Hide comment
@X286

X286 Aug 29, 2016

@jaraco
Traceback (most recent call last):
File "E:/NFC_Operator/testssh.py", line 3, in
ctypes.c_ssize_t
AttributeError: 'module' object has no attribute 'c_ssize_t'
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
yep,
code "import ctypes, sys; print(sys.version); ctypes.c_ssize_t"
gives me error too.
oh i read your fix.
Thank you.

X286 commented Aug 29, 2016

@jaraco
Traceback (most recent call last):
File "E:/NFC_Operator/testssh.py", line 3, in
ctypes.c_ssize_t
AttributeError: 'module' object has no attribute 'c_ssize_t'
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
yep,
code "import ctypes, sys; print(sys.version); ctypes.c_ssize_t"
gives me error too.
oh i read your fix.
Thank you.

@jaraco

This comment has been minimized.

Show comment
Hide comment
@jaraco

jaraco Aug 31, 2016

Contributor

That's interesting that Python 2.7.12 is missing that attribute. I wonder if there's something new about that release that removed that attribute, perhaps by mistake.

Contributor

jaraco commented Aug 31, 2016

That's interesting that Python 2.7.12 is missing that attribute. I wonder if there's something new about that release that removed that attribute, perhaps by mistake.

@jaraco

This comment has been minimized.

Show comment
Hide comment
@jaraco

jaraco Aug 31, 2016

Contributor

I just installed the latest Python (admittedly 64-bit version), and it has that attribute. I think there may be something corrupted in your installation.

C:\Users\jaraco> py -2
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.c_ssize_t
<class 'ctypes.c_longlong'>
Contributor

jaraco commented Aug 31, 2016

I just installed the latest Python (admittedly 64-bit version), and it has that attribute. I think there may be something corrupted in your installation.

C:\Users\jaraco> py -2
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.c_ssize_t
<class 'ctypes.c_longlong'>
@jaraco

This comment has been minimized.

Show comment
Hide comment
@jaraco

jaraco Aug 31, 2016

Contributor

32-bit version also has the attribute. I think we can confidently say that the issue is isolated to your installation.

C:\Users\jaraco> py -2.7-32
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.c_ssize_t
<class 'ctypes.c_long'>
Contributor

jaraco commented Aug 31, 2016

32-bit version also has the attribute. I think we can confidently say that the issue is isolated to your installation.

C:\Users\jaraco> py -2.7-32
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.c_ssize_t
<class 'ctypes.c_long'>
@X286

This comment has been minimized.

Show comment
Hide comment
@X286

X286 Aug 31, 2016

@jaraco
Thank you.
I'm sorry to have spent your time .

X286 commented Aug 31, 2016

@jaraco
Thank you.
I'm sorry to have spent your time .

@bitprophet

This comment has been minimized.

Show comment
Hide comment
@bitprophet

bitprophet Sep 7, 2016

Member

Thanks for digging @jaraco !

Member

bitprophet commented Sep 7, 2016

Thanks for digging @jaraco !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment