1

I am trying to make a bot on discord which will play music from youtube, I watched a tutorial on how its made and the code is basically identical yet this error is thrown after I try to run the code.

import discord
import youtube_dl
import music
from discord.ext import commands
client = discord.Client()
client = commands.Bot(command_prefix='!', intents = discord.Intents.all)
cogs = [music]
for i in range(len(cogs)):
    cogs[i].setup(client)


    @commands.command()
    async def join (self, ctx):
        if ctx.author.voice is None:
            await ctx.send("You're not in a voice channel")
        voice_channel = ctx.author.voice.channel
        if ctx.voice_client is None:
            await voice_channel.connect()
        else:
            await ctx.voice_client.move_to(voice_channel)

    
    @commands.command()
    async def disconnect (self, ctx):
        await ctx.voice_client.disconnect()
    
    @commands.command()
    async def pause (self, ctx):
        await ctx.voice_client.pause()
        await ctx.send("Paused ")
    
    
    @commands.command()
    async def play (self, ctx, url):
        ctx.voice_client.stop()
        FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options':'vn'}
        YDL_OPTIONS= {'format':"bestaudio"}
        vc = ctx.voice_client

        with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
            info = ydl.extract_info(url, download=False)
            url2 = info['formats'][0]['url']
            source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
            vc.play(source)
        

When executing in terminal this error occurs.

File "c:\Users\*\\Documents\VSCode\Python\musicbotc.py", line 
3, in <module>
    import music
  File "C:\Users\*\AppData\Local\Programs\Python\Python39\lib\site-packages\music\__init__.py", line 1, in <module>
    from .utils import H
  File "C:\Users\*\AppData\Local\Programs\Python\Python39\lib\site-packages\music\utils.py", line 5, in <module>
    from . import core
ImportError: cannot import name 'core' from partially initialized module 'music' (most likely due to a circular import) (C:\Users\*\AppData\Local\Programs\Python\Python39\lib\site-packages\music\__init__.py) 

I have tried not importing music at all but it seems like that only opens the project to even more errors. Any fixes or suggestions are appreciated thankyou.

ye west
  • 37
  • 6
  • Does [this](https://stackoverflow.com/questions/46377697/music-library-will-not-import-using-python-3-6-on-a-windows-7-machine#comment83537731_46377697) and [this](https://stackoverflow.com/a/66055075/16136190) help? – The Amateur Coder Jan 23 '22 at 08:02

0 Answers0