python - Pyomegle : ImportError: cannot import name 'OmegleClient' from partially initialized module

标签 python python-2.7

我正在尝试编写一个 pyomegle 机器人,但每次我尝试运行它时都会收到此错误。我已经尝试使用 interpreterterminal 运行它,但都没有成功。我正在使用 Python 版本 2.7.17 32 位 并且已经尝试过版本 3.8.1 32 位,并使用 vscode 作为文本编辑器.

pip --version 产生:

pip 20.0.2 from c:\users\MYNAME\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8)

pip freeze 产生:

aiohttp==3.6.2
astroid==2.3.3
async-timeout==3.0.1
attrs==19.3.0
autopep8==1.5
beautifulsoup4==4.8.2
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
colorama==0.4.3
colored==1.4.2
discord.py==1.3.2
html5lib==1.0.1
idna==2.9
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
mechanize==0.4.5
multidict==4.7.5
pycodestyle==2.5.0
pycparser==2.19
pygame==1.9.6
pylint==2.4.4
PyNaCl==1.3.0
pyomegle==1.5
requests==2.23.0
six==1.13.0
soupsieve==2.0
toml==0.10.0
urllib3==1.25.8
webencodings==0.5.1
websockets==8.1
wrapt==1.11.2
yarl==1.4.2
youtube-dl==2020.2.16
youtube-search==0.1.3

我已经使用下面的命令安装了pyomegle:

pip 安装 pyomegle

这是我每次尝试运行它时收到的错误:

Traceback (most recent call last):
  File "c:\Users\MYNAME\Desktop\pyomegle.py", line 1, in <module>
    from pyomegle import OmegleClient, OmegleHandler
  File "c:\Users\MYNAME\Desktop\pyomegle.py", line 1, in <module>
    from pyomegle import OmegleClient, OmegleHandler
ImportError: cannot import name 'OmegleClient' from partially initialized module 'pyomegle' (most likely due to a circular import) (c:\Users\MYNAME\Desktop\pyomegle.py)

这是我的代码,没有其他文件与之关联:

from pyomegle import OmegleClient, OmegleHandler

"""
    Omegle inteface for python

    /next
        starts a new conversation
    /exit
        exits chat session
"""

h = OmegleHandler(loop=True)            # session loop
c = OmegleClient(h, wpm=47, lang='en')  # 47 words per minute
c.start()

while 1:
    input_str = raw_input('')           # string input

    if input_str.strip() == '/next':
        c.next()                        # new conversation
    elif input_str.strip() == '/exit':
        c.disconnect()                  # disconnect chat session
        break
    else:
        c.send(input_str)               # send string

我主要从位于此处的官方 GitHub 存储库中的自述文件中复制了 pyomegle 示例:https://github.com/elias94/pyomegle

最佳答案

我在使用 atom 作为编辑器时遇到了这个问题,我改用 IDLE 修复了它。

编辑:出于不同原因重新安装 python 后,这不再有效。

关于python - Pyomegle : ImportError: cannot import name 'OmegleClient' from partially initialized module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60677343/

相关文章:

python - 数据框中的条件串联

python - Numpy 压缩函数

python-2.7 - 将 Python 中的数字表列表保存为 Mathematica 易于阅读的格式?

python - 如何在 BeautifulSoup 中找到 `td` 父标签的所有 `tr` 且具有 `class="Accordion-toggle main-row"' 的父标签?

python - PyCharm 可以列出项目中的所有 Python 错误吗?

python - 用 Python 抓取具有可点击内容的网站

python - 在 Python 中使用正则表达式查找和替换文件中的单词列表

Python Pandas to_pickle 无法 pickle 大型数据帧

python - 验证 django 内联表单集

python - 为 jython 脚本创建可执行文件