Error with Circular Importing in PyCharm and discord.py

Viewed 98

I am trying to get code autocomplete to work with discord.py in PyCharm. I have already imported discord and discord.ext in the code and I've used pip to install discord. Then, I changed the Project Structure and added the discord folder as a source. The bot runs fine until I try to add the discord folder as source. Here is the shortened code for the bot (other imports are for irrelevant portions of code):

#!/usr/bin/env python
import discord
from discord.ext import commands
from discord import FFmpegPCMAudio
import asyncio
from datetime import datetime
from mutagen.mp3 import MP3
import instream
import outstream
import os

# Initializes Bot
client = commands.Bot(command_prefix='$')
intents = discord.Intents(messages=True, guilds=True, reactions=True, members=True, presences=True)

# Confirms date and time when bot is started
@client.event
async def on_ready():
    print('[+] Intro Bot Started at: ' + str(datetime.now()))

client.run('token')

The code autocompletes but when I run, I get this error:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\io.py", line 52, in <module>
  File "C:\Users\Frank\PycharmProjects\discord.py-1.7.3\discord\abc.py", line 29, in <module>
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\copy.py", line 52, in <module>
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\weakref.py", line 24, in <module>
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2800.0_x64__qbz5n2kfra8p0\lib\_collections_abc.py", line 9, in <module>
ImportError: cannot import name 'ABCMeta' from partially initialized module 'abc' (most likely due to a circular import) (C:\Users\Frank\PycharmProjects\discord.py-1.7.3\discord\abc.py)

I've tried pip freeze in the terminal as well as removing the import lines of code. I can make the discord folder not a source in Project Structure every time I want to run, but it takes a long time when I'm running the bot every few minutes. How can I run my bot with autocomplete on?

0 Answers
Related