LinDRon
2017-06-18 01:56
采纳率: 25%
浏览 6.1k
已采纳

import socket模块出现异常

不知道是什么原因,求解决办法,感谢!!

import socket
Traceback (most recent call last):
File "", line 1, in
File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in
udpSocket = socket.socket()
TypeError: 'module' object is not callable
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
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in
from urllib.request import urlopen
File "/usr/lib/python3.5/urllib/request.py", line 88, in
import http.client
File "/usr/lib/python3.5/http/client.py", line 71, in
import email.parser
File "/usr/lib/python3.5/email/parser.py", line 12, in
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.5/email/feedparser.py", line 27, in
from email import message
File "/usr/lib/python3.5/email/message.py", line 16, in
from email import utils
File "/usr/lib/python3.5/email/utils.py", line 29, in
import socket
File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in
udpSocket = socket.socket()
TypeError: 'module' object is not callable

Original exception was:
Traceback (most recent call last):
File "", line 1, in
File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in
udpSocket = socket.socket()
TypeError: 'module' object is not callable

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • oyljerry 2017-06-18 04:59
    最佳回答

    你的源码文件不要用socket.py,他跟系统模块名字冲突了。改个名字,比如sock_test.py

     File "/home/python/PycharmProjects/own/internet_compile/socket.py", line 3, in 
    
    评论
    解决 7 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题