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

Cannot choose from an empty sequence #57

Closed
metulburr opened this Issue Nov 2, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@metulburr

metulburr commented Nov 2, 2017

I have been having a lot of problems today regarding fake_useragent. In a real world example of using selenium, but i cant even get it to pull the string at all either.

Python 3.6.1 (default, Jun  8 2017, 06:36:16) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fake_useragent import UserAgent as UA
>>> ua = UA()
>>> ua.random
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 136, in __getattr__
    return random.choice(self.data_browsers[browser])
  File "/usr/local/lib/python3.6/random.py", line 257, in choice
    raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 139, in __getattr__
    raise FakeUserAgentError('Error occurred during getting browser')  # noqa
fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser
>>> ua.VERSION
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 136, in __getattr__
    return random.choice(self.data_browsers[browser])
KeyError: 'version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 139, in __getattr__
    raise FakeUserAgentError('Error occurred during getting browser')  # noqa
fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser
>>> ua.chrome
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 136, in __getattr__
    return random.choice(self.data_browsers[browser])
  File "/usr/local/lib/python3.6/random.py", line 257, in choice
    raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 139, in __getattr__
    raise FakeUserAgentError('Error occurred during getting browser')  # noqa
fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser
>>> ua['google chrome']
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 136, in __getattr__
    return random.choice(self.data_browsers[browser])
  File "/usr/local/lib/python3.6/random.py", line 257, in choice
    raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 119, in __getitem__
    return self.__getattr__(attr)
  File "/usr/local/lib/python3.6/site-packages/fake_useragent/fake.py", line 139, in __getattr__
    raise FakeUserAgentError('Error occurred during getting browser')  # noqa
fake_useragent.errors.FakeUserAgentError: Error occurred during getting browser
>>> 

another traceback with selenium at
#41

@mmelih

This comment has been minimized.

Show comment
Hide comment
@mmelih

mmelih Nov 2, 2017

I think this is the reason: http://useragentstring.com/pages/useragentstring.php?name=chrome

Connection could not be established !!
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

mmelih commented Nov 2, 2017

I think this is the reason: http://useragentstring.com/pages/useragentstring.php?name=chrome

Connection could not be established !!
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

@hellysmile

This comment has been minimized.

Show comment
Hide comment
@hellysmile

hellysmile Nov 3, 2017

Owner

fix is on a way, ~ 30 min

Owner

hellysmile commented Nov 3, 2017

fix is on a way, ~ 30 min

@hellysmile

This comment has been minimized.

Show comment
Hide comment
@hellysmile

hellysmile Nov 3, 2017

Owner

@mmelih @metulburr @thinkxl 0.1.8 is on PyPi!!! Can You confirm that issues is fixed?

Owner

hellysmile commented Nov 3, 2017

@mmelih @metulburr @thinkxl 0.1.8 is on PyPi!!! Can You confirm that issues is fixed?

@leips

This comment has been minimized.

Show comment
Hide comment
@leips

leips Nov 3, 2017

@hellysmile Yeah, It's working!

leips commented Nov 3, 2017

@hellysmile Yeah, It's working!

@hellysmile hellysmile closed this Nov 3, 2017

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