Skip to content
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

'NoneType' object has no attribute 'setdefault' IN python module #270

Open
sxp4u opened this issue Oct 28, 2018 · 8 comments
Open

'NoneType' object has no attribute 'setdefault' IN python module #270

sxp4u opened this issue Oct 28, 2018 · 8 comments

Comments

@sxp4u
Copy link

sxp4u commented Oct 28, 2018

Here is my code, just same as what's in README.md

import bitmex

client = bitmex.bitmex()
result = client.Quote.Quote_get(symbol="XBTUSD", reverse=True, count=1).result()

print(result[0][0]['bidSize'])

then it incur an exception message like this:

Traceback (most recent call last):
  File "/Users/shi/PycharmProjects/crypoarbitrage/bitmex_api.py", line 3, in <module>
    client = bitmex.bitmex()
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bitmex.py", line 38, in bitmex
    return SwaggerClient.from_url(spec_uri, config=config)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/client.py", line 96, in from_url
    spec_dict = loader.load_spec(spec_url)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/swagger_model.py", line 104, in load_spec
    self.request_headers,
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/http_future.py", line 213, in result
    incoming_response = self._get_incoming_response(timeout)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/http_future.py", line 97, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/http_future.py", line 228, in _get_incoming_response
    inner_response = self.future.result(timeout=timeout)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/requests_client.py", line 310, in result
    self.misc_options['ssl_cert'],
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/requests/sessions.py", line 688, in merge_environment_settings
    proxies.setdefault(k, v)
AttributeError: 'NoneType' object has no attribute 'setdefault'

Do I config something wrong ? Is there anybody give me some hint ?

@sxp4u
Copy link
Author

sxp4u commented Oct 29, 2018

Actually, you can reproduce the issue using:

import bitmex

client = bitmex.bitmex()
# result = client.Quote.Quote_get(symbol="XBTUSD", reverse=True, count=1).result()

# print(result[0][0]['bidSize'])

the error message is the same:

Traceback (most recent call last):
  File "/Users/shi/PycharmProjects/crypoarbitrage/bitmex_api.py", line 3, in <module>
    client = bitmex.bitmex()
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bitmex.py", line 38, in bitmex
    return SwaggerClient.from_url(spec_uri, config=config)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/client.py", line 96, in from_url
    spec_dict = loader.load_spec(spec_url)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/swagger_model.py", line 104, in load_spec
    self.request_headers,
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/http_future.py", line 213, in result
    incoming_response = self._get_incoming_response(timeout)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/http_future.py", line 97, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/http_future.py", line 228, in _get_incoming_response
    inner_response = self.future.result(timeout=timeout)
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/bravado/requests_client.py", line 310, in result
    self.misc_options['ssl_cert'],
  File "/Users/shi/anaconda/envs/unibook/lib/python3.6/site-packages/requests/sessions.py", line 688, in merge_environment_settings
    proxies.setdefault(k, v)
AttributeError: 'NoneType' object has no attribute 'setdefault'

@sxp4u
Copy link
Author

sxp4u commented Nov 2, 2018

I create a brand new Conda environment bitmex, enter it.
run pip install bitmex, still have this problem.

(bitmex) shi-MacBook-Pro:bitmex shi$ pip list 
Package                Version   
---------------------- ----------
bitmex                 0.2.2     
bravado                10.2.0    
bravado-core           5.0.7     
certifi                2018.10.15
chardet                3.0.4     
django-polls           0.1       
idna                   2.7       
jsonref                0.2       
jsonschema             2.6.0     
monotonic              1.5       
msgpack-python         0.5.6     
pip                    18.1      
python-dateutil        2.7.5     
pytz                   2018.7    
PyYAML                 3.13      
requests               2.20.0    
rfc3987                1.3.8     
setuptools             36.4.0    
simplejson             3.16.0    
six                    1.11.0    
strict-rfc3339         0.7       
swagger-client         1.0.0     
swagger-spec-validator 2.4.1     
urllib3                1.24      
webcolors              1.8.1     
wheel                  0.29.0    
(bitmex) shi-MacBook-Pro:bitmex shi$ ll
total 8
drwxr-xr-x  3 shixiaopeng  staff   96 11  2 17:38 .
drwxr-xr-x  8 shixiaopeng  staff  256 11  2 17:33 ..
-rw-r--r--  1 shixiaopeng  staff   42 11  2 17:38 demo.py
(bitmex) shi-MacBook-Pro:bitmex shi$ cat demo.py
import bitmex

client = bitmex.bitmex()


(bitmex) shi-MacBook-Pro:bitmex shi$ python demo.py 
Traceback (most recent call last):
  File "demo.py", line 3, in <module>
    client = bitmex.bitmex()
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bitmex.py", line 38, in bitmex
    return SwaggerClient.from_url(spec_uri, config=config)
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bravado/client.py", line 96, in from_url
    spec_dict = loader.load_spec(spec_url)
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bravado/swagger_model.py", line 104, in load_spec
    self.request_headers,
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bravado/http_future.py", line 213, in result
    incoming_response = self._get_incoming_response(timeout)
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bravado/http_future.py", line 97, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bravado/http_future.py", line 228, in _get_incoming_response
    inner_response = self.future.result(timeout=timeout)
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/bravado/requests_client.py", line 310, in result
    self.misc_options['ssl_cert'],
  File "/Users/shi/anaconda/envs/bitmex/lib/python3.6/site-packages/requests/sessions.py", line 693, in merge_environment_settings
    proxies.setdefault(k, v)
AttributeError: 'NoneType' object has no attribute 'setdefault'
(bitmex) shi-MacBook-Pro:bitmex shi$ 

@Jrzg1992
Copy link

Jrzg1992 commented Dec 1, 2018

Have you solved the problem?I have the same problem.

@sxp4u
Copy link
Author

sxp4u commented Dec 4, 2018

This problem is associated with proxies. When I open Lantern, this problem appear, and when I close Lantern this problem disappear.

@sxp4u
Copy link
Author

sxp4u commented Dec 4, 2018

Have you solved the problem?I have the same problem.

I solve this problem by Quiting Lantern, and using OpenVPN build on my cloud server.

@sxp4u
Copy link
Author

sxp4u commented Dec 4, 2018

Also, this may be helpful @wyxr
Yelp/bravado#361

@Fzkbnb
Copy link

Fzkbnb commented Dec 12, 2018

Have you solved the problem?I have the same problem.

me too

@LourensVeen
Copy link

This seems to be a Bravado issue, see Yelp/bravado#401. You could try downgrading to Bravado 10.1.0, that worked for me.

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

No branches or pull requests

4 participants