ImportError:无法导入名称uuid4

时间:2015-10-30 04:44:49

标签: python pycharm

#-*- encoding: utf-8 -*-

__author__ = 'Administrator'
from bs4 import BeautifulSoup
import requests

def parse_row(input_row, parsers):
    """given a list of pasers (some of which may be None)
    apply the appropriate one to each element of the input_row"""
    return [parser(value) if parser is not None else value
             for value, parser in zip(input_row, parsers)]

if __name__ == "__main__":
    url = "http://news.china.com.cn/2015-10/28/content_36911585.htm"
    soup = BeautifulSoup(requests.get(url.strip()).text, 'html5lib')

这是我在pycharm IDE中的代码。错误是

"Traceback (most recent call last):

  File "D:\Program Files\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 98, in <module>

    from pydevd_plugin_utils import PluginManager

  File "D:\Program Files\PyCharm Community Edition 

4.5.4\helpers\pydev\pydev_monkey_qt.py", line 71, in patched_import

    return original_import(name, *args, **kwargs)

  File "D:\Program Files\PyCharm Community Edition 

4.5.4\helpers\pydev\pydevd_plugin_utils.py", line 5, in <module>

    from _pydev_imps._pydev_pluginbase import PluginBase

  File "D:\Program Files\PyCharm Community Edition 

4.5.4\helpers\pydev\pydev_monkey_qt.py", line 71, in patched_import

    return original_import(name, *args, **kwargs)

  File "D:\Program Files\PyCharm Community Edition 

4.5.4\helpers\pydev\_pydev_imps\_pydev_pluginbase.py", line 20, in <module>

    from uuid import uuid4

ImportError: cannot import name uuid4"

1 个答案:

答案 0 :(得分:1)

您确定项目目录中没有名为 uuid.py 的python文件吗?

永远不要在python模块之后命名你的python文件;)