Selenium Python Ubuntu-导入http.client AttributeError

时间:2016-01-29 17:17:10

标签: python ubuntu selenium selenium-webdriver http.client

这是我与这个错误作斗争的日子。 我的背景是: - 清洁安装Lubuntu(基于ubuntu 15),只安装了setuptools和selenium 2.50 - selenium python3脚本。

我尝试使用其他机器(基于ubuntu 14的lubuntu)运行此脚本并运行,但是使用新机器,所有脚本都不起作用。 我抬头看着大网,但我无法找到答案。 我有以下错误:

Traceback (most recent call last):
File "tesst.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/__init__.py", line 18, in <module>
from selenium import selenium
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/selenium.py", line 23, in <module>
import http.client as http_client
File "/usr/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/usr/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedpaarser import FeedParser, BytesFeedParser
File "/usr/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.4/email/message.py", line 16, in <module>
from email import utils
File "/usr/lib/python3.4/email/utils.py", line 33, in <module>
from email._parseaddr import quote
File "/usr/lib/python3.4/email/_parseaddr.py", line 16, in <module>
import time, calendar
File "/home/XXXX/Scripts/XXXX/calendar.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/webdriver/__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/webdriver/firefox/webdriver.py", line 20, in <module>
import http.client as http_client
AttributeError: 'module' object has no attribute 'client'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
from urllib.request import urlopen
File "/usr/lib/python3.4/urllib/request.py", line 88, in <module>
import http.client
File "/usr/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/usr/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.4/email/message.py", line 16, in <module>
from email import utils
File "/usr/lib/python3.4/email/utils.py", line 33, in <module>
from email._parseaddr import quote
File "/usr/lib/python3.4/email/_parseaddr.py", line 16, in <module>
import time, calendar
File "/home/XXXX/Scripts/XXXX/calendar.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/__init__.py", line 18, in <module>
from selenium import selenium
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/selenium.py", line 23, in <module>
import http.client as http_client
AttributeError: 'module' object has no attribute 'client'

Original exception was:
Traceback (most recent call last):
File "tesst.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/__init__.py", line 18, in <module>
from selenium import selenium
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/selenium.py", line 23, in <module>
import http.client as http_client
File "/usr/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/usr/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.4/email/message.py", line 16, in <module>
from email import utils
File "/usr/lib/python3.4/email/utils.py", line 33, in <module>
from email._parseaddr import quote
File "/usr/lib/python3.4/email/_parseaddr.py", line 16, in <module>
import time, calendar
File "/home/XXXX/Scripts/XXXX/calendar.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/webdriver/__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox
File "/usr/local/lib/python3.4/dist-packages/selenium-2.50.0-py3.4.egg/selenium/webdriver/firefox/webdriver.py", line 20, in <module>
    import http.client as http_client

在来到这里之前我看了很多,但我现在有点失落了。有人可以帮忙,我会非常感激。 谢谢!!

编辑:

嘿,我已经尝试了所有这些,但它没有解决问题。我没有重复的硒,我只是安装 硒中sudo python3 setup.py install。另外,我没有一个名为http.py的脚本,所以当我import http http.__file__时,它会给我/usr/lib/python3.4/http/__init__.py

1 个答案:

答案 0 :(得分:0)

好吧,让我们面对现实吧,我知道,答案就在眼前。 S ** t !! 这个     文件“/home/XXXX/Scripts/XXXX/calendar.py”,第1行,

我有一个脚本名称calendar.py作为模块......所以更改名称就成了工作。

对不起伙计们,谢谢你们