1

The code using Selenium webdriver shows me error after setup.

I tried to setup different ways: for Google web driver, for Firefox.
I tried with and without showing the path to the driver (Chrome driver and gecko driver that we can find on Stack Overflow)
I tried to show the path with and without raw before the path to the file
I tried to find similar issues on Internet but didn't found.

Here is the code:

from selenium import webdriver as wd

driver = wd.Firefox(executable_path=r'C:\Users\User\Downloads\geckodriver-v0.24.0-win64')
driver.get('https://youtube.com')

I was expecting the code lauching Firefox then go on YouTube it shows me this:

   (most recent call last):
  File "C:/Users/User/.PyCharmCE2018.3/config/scratches/tringseln.py", line 1, in <module>
    from selenium import webdriver as wd
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 29, in <module>
    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 27, in <module>
    from .remote_connection import RemoteConnection
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 24, in <module>
    import urllib3
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\urllib3\__init__.py", line 7, in <module>
    from .connectionpool import (
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import (
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
    mod = mod._resolve()
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "C:\Users\User\PycharmProjects\instasubs and generators\venv\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 71, in <module>
    import email.parser
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\email\parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\email\feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\email\_policybase.py", line 9, in <module>
    from email.utils import _has_surrogates
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\email\utils.py", line 30, in <module>
    import datetime
  File "C:\Users\User\.PyCharmCE2018.3\config\scratches\datetime.py", line 2, in <module>
    tday = datetime.datetime.today()
AttributeError: module 'datetime' has no attribute 'today'

If someone helps me would be really great. Thanks for your time.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

3 Answers3

2

Just import the whole datetime module i guess: from datetime import datetime

1

This error is from the line of code in your script.

tday = datetime.datetime.today()  # <===== there is no today method `today` for datetime

Check this error message in trackback AttributeError: module 'datetime' has no attribute 'today'

supputuri
  • 13,644
  • 2
  • 21
  • 39
  • well thanks for you anser ;) . i checked it but the problem seem to come from the datetime library and not the selenium, what should i do ? reinstall it or maybe specifiy and import datetime ? thanks for your time – pandasansgains Jun 01 '19 at 15:13
  • add `import datetime`. – supputuri Jun 01 '19 at 15:23
0

The issue is probably comming from my Pycharm. I solved it by using the Python original console with the library(installed of curse). So if you have the same issue I reccomend to use another console or interpreter. The problem is'nt solved by itself but it's a good ersatz.