Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

Error when importing requests_ntlm #6

Closed
LiaungYip opened this issue Jan 5, 2015 · 9 comments
Closed

Error when importing requests_ntlm #6

LiaungYip opened this issue Jan 5, 2015 · 9 comments

Comments

@LiaungYip
Copy link

As reported at requests/requests-ntlm#54 :


Attempting to import requests_ntlm on Python 2.7.9 raises a TypeError. This renders the module unusable.

See also this StackOverflow question about a very similar error: http://stackoverflow.com/questions/27660034/python-requests-ntlm-import-error . (The user in that post got a 'long' object is not subscriptable error. I had also experienced that error before updating Python to latest.)

PS C:\Users\lws> python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests_ntlm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\requests_ntlm\__init__.py", line 1, in <module>
    from .requests_ntlm import HttpNtlmAuth
  File "C:\Python27\lib\site-packages\requests_ntlm\requests_ntlm.py", line 4, in <module>
    from ntlm3 import ntlm
  File "C:\Python27\lib\site-packages\ntlm3\__init__.py", line 2, in <module>
    from . import HTTPNtlmAuthHandler  # noqa
  File "C:\Python27\lib\site-packages\ntlm3\HTTPNtlmAuthHandler.py", line 20, in <module>
    from . import ntlm
  File "C:\Python27\lib\site-packages\ntlm3\ntlm.py", line 25, in <module>
    from . import des
  File "C:\Python27\lib\site-packages\ntlm3\des.py", line 19, in <module>
    from . import des_c
  File "C:\Python27\lib\site-packages\ntlm3\des_c.py", line 19, in <module>
    from .des_data import des_SPtrans, des_skb
  File "C:\Python27\lib\site-packages\ntlm3\des_data.py", line 25, in <module>
    U32(0x00820200), U32(0x00020000), U32(0x80800000), U32(0x80820200),
  File "C:\Python27\lib\site-packages\ntlm3\U32.py", line 32, in __init__
    value = six.byte2int(value)
  File "C:\Python27\lib\site-packages\six.py", line 625, in byte2int
    return ord(bs[0])
TypeError: 'long' object has no attribute '__getitem__'
>>>

Package versions in use:

PS C:\Users\lws> pip show requests-ntlm requests python-ntlm3 six

---
Name: requests-ntlm
Version: 0.1.0
Location: c:\python27\lib\site-packages
Requires: requests, python-ntlm3

---
Name: requests
Version: 2.5.1
Location: c:\python27\lib\site-packages
Requires:

---
Name: python-ntlm3
Version: 1.0.1
Location: c:\python27\lib\site-packages
Requires: six

---
Name: six
Version: 1.9.0
Location: c:\python27\lib\site-packages
Requires:

A further note; requests_ntlm version 0.0.3 imports OK. All other dependency versions are unchanged.

PS C:\Users\lws> pip install requests-ntlm==0.0.3
Downloading/unpacking requests-ntlm==0.0.3
  Downloading requests_ntlm-0.0.3.tar.gz
  Running setup.py (path:c:\users\lws\appdata\local\temp\pip_build_lws\requests-ntlm\setup.py) egg_info for package requests-ntlm

Requirement already satisfied (use --upgrade to upgrade): requests>=1.0.0 in c:\python27\lib\site-packages (from requests-ntlm==0.0.3)
Requirement already satisfied (use --upgrade to upgrade): python-ntlm in c:\python27\lib\site-packages (from requests-ntlm==0.0.3)
Installing collected packages: requests-ntlm
  Running setup.py install for requests-ntlm

Successfully installed requests-ntlm
Cleaning up...
PS C:\Users\lws> python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests_ntlm
>>>
@catermelon
Copy link
Collaborator

Thanks for the report and sorry for the bug. It must be something oddball with Windows, because it's passing Travis just fine and I tested on OS X by hand.

In the meantime, feel free to use requests-ntlm 0.0.3. That uses the older python-ntlm library which isn't Python 3 compatible.

@LiaungYip
Copy link
Author

Thanks, this is for a one-use throw-away script so using an old version of requests_ntlm is fine. Let me know if you need anything tested.

@sigmavirus24
Copy link

@trustrachel fwiw, you can add AppVeyor for Windows CI

@carsonyl
Copy link

carsonyl commented Jan 5, 2015

I have a proposed fix in #7, which works for me. Please take a look!

@catermelon
Copy link
Collaborator

@sigmavirus24 - thanks, I was just looking around for what my options are for that!

@rbcarson - awesome, let me take a look.

catermelon pushed a commit that referenced this issue Jan 6, 2015
Recognize long integers as integers. Fixes #6.
@catermelon
Copy link
Collaborator

Hey @LiaungYip, I just released v1.0.2, can you check this works for you now?

@catermelon catermelon reopened this Jan 7, 2015
@LiaungYip
Copy link
Author

I've just updated to 1.0.2. I'm on a different PC with different version of Python but all seems to be well. I'll test again on my original computer when I get home.

PS C:\Users\layip\> pip freeze
python-ntlm==1.1.0
python-ntlm3==1.0.2
requests==2.5.1
requests-ntlm==0.1.0
six==1.9.0

PS C:\Users\layip\> python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests_ntlm
>>>

@LiaungYip
Copy link
Author

Importing requests-ntlm works for me after upgrading to latest python-ntlm3, on the computer which originally exhibited the bug.

> pip list
python-ntlm (1.1.0)
python-ntlm3 (1.0.2)
requests (2.5.1)
requests-ntlm (0.1.0)
requests-toolbelt (0.3.1)
six (1.9.0)
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests_ntlm
>>>

@catermelon
Copy link
Collaborator

Awesome, I'm glad.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants