Django环境搭建记录

环境:

** Fedora24 X64**
python3.5(自带)
Django 1.9
selenium(2.53.6)
Firefox 47.0.1

搭建记录

1 . 使用Django 1.7的时候报了如下错误:

  File "/usr/lib/python3.5/site-packages/django/utils/html_parser.py", line 12, in 
    HTMLParseError = _html_parser.HTMLParseErro

查: http://stackoverflow.com/questions/34827566/attributeerror-module-html-parser-has-no-attribute-htmlparseerror

As you can read here this error is raised...
because HTMLParseError is deprecated from Python 3.3 onwards and removed in Python 3.5.
what you can do is downgrade your Python version or upgrade your Django version.

获得解决办法:把Django升级到1.9或者降低python版本

2 . selenium启动Firefox报错

Traceback (most recent call last):
    browser = webdriver.Firefox()
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
    self.binary, timeout)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 99, in _wait_until_connectable
    "The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

或者这个错误信息:

Traceback (most recent call last):
  File "functional_test.py", line 4, in 
    browser = webdriver.Firefox()
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 85, in __init__
    keep_alive=True)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 401, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 433, in _request
    resp = self._conn.getresponse()
  File "/usr/lib64/python3.5/http/client.py", line 1174, in getresponse
    response.begin()
  File "/usr/lib64/python3.5/http/client.py", line 282, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.5/http/client.py", line 243, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib64/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

查到: http://stackoverflow.com/questions/37693106/selenium-2-53-not-working-on-firefox-47/37693374

获得解决办法:降低Firefox版本到46以下

7月3日更新: 最新版本的Firefox已经支持了2.53版本的selenium
坑!

你可能感兴趣的:(Django环境搭建记录)