Reputation: 1
I'm using VS Code on my laptop, and ever since I created a circular import error message in my terminal, I have not been able to get rid of it. I tried everything from making obvious changes to the code, to clearing the cache, to a complete uninstall of any reference to VS Code, and the issue still persist,. I have since fixed the issue with the circular import using my desktop, and if I run the new code on my laptop, I get the same error message as before, even though I know the circular import isn't with my current code. Any idea what it can be or how I can fix this issue so I can continue to use my laptop to code?
This is the feedback I get within my terminal, no matter what code I enter.
Traceback (most recent call last):
File "c:\Users\kdogg\OneDrive\Desktop\Anime-Ultimate\AnimeUltimateBot\main.py", line 2, in <module>
from discord.ext import commands
File "C:\Users\kdogg\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\__init__.py", line 11, in <module>
from .bot import *
File "C:\Users\kdogg\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 38, in <module>
from .core import GroupMixin
File "C:\Users\kdogg\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\core.py", line 9, in <module>
class PlayerProfiles(commands.Bot):
^^^^^^^^^^^^
AttributeError: partially initialized module 'discord.ext.commands' has no attribute 'Bot' (most likely due to a circular import)
PS C:\Users\kdogg\OneDrive\Desktop\Anime-Ultimate>
I tried completely deleting the file where the circular import was happening, and my output was the same error message. Tried uninstalling vs code, and deleting app data and all. I reinstalled it, ran the new code that works, and still got the same error.
Upvotes: -1
Views: 120
Reputation: 46
Delete all pycache folders in your project directory. you can do this with this code
find . -type d -name "__pycache__" -exec rm -r {} +
check if you are using the correct python environment Open the Command Palette (Ctrl+Shift+P). Type Python: Select Interpreter and choose the right one.
uninstall and install discord library
pip uninstall discord discord.py
pip install discord.py
create new env
python -m venv newenv
source newenv/bin/activate [ On Windows, use `newenv\Scripts\activate`]
pip install discord.py
ensure no other files named discord.py or commands.py in your project that might conflict with the library.
Restart VS Code
Upvotes: 0