#๐ Module not found issue
85 messages ยท Page 1 of 1 (latest)
@upbeat crescent
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Just in case pip is not associated with the Python which py runs, try: py -m pip install python-dotenv
The usual cause of problems like these is that pip installed into a different environment from the environment you're running the script with.
py -m pip runs pip in the environment py is using.
I got the same message
It installed but then when i ran command py main.py i got the same modulenotfounderror
@robust bane
I just realized the new error message is discord now not dotenv
So do i need to run every module install through py?
@upbeat crescent yes, all third party modules need installing via py -m pip. Just the once.
So now you need py -m pip install discord
Okay when i go to install aiohttp it fails
You'll need to show the error.
Would i be able to run the command "py - pip install -r requirements.txt'?
Please copy/paste as text, not a screenshot.
Okay one sec
Yes.
It isnt letting me upload this txt file because the coding is long
Collecting opencv-python==4.8.0.76 (from -r requirements.txt (line 35))
Using cached opencv-python-4.8.0.76.tar.gz (92.1 MB)
Installing build dependencies ... error
error: subprocess-exited-with-error
ร pip subprocess to install build dependencies did not run successfully.
โ exit code: 2
โฐโ> [144 lines of output]
Anything you can do with pip, you can do with py -m pip. Both call the same module in the end; the only difference is which Python interpreter is used to call it.
Using py -m pip ensures it's the right environment.
Okay
!paste
for larger text
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
!paste
Read this embed for instructions, please.
Try py -m pip install --prefer-binary -r requirements.txt
Running it now
Funky one. Latest Python versions removed setuptools, which is the cause of distutils missing.
Please call py -m pip install setuptools
I believe i did that earlier from watching a yt video
Though there are later versions of opencv-python that I'm sure alleviate this
!pypi opencv-python
Have a look in requirements.txt, line 35. Does it specify this particular version of opencv-python? Because 4.8 is somewhat behind.
Oh, you're using Python 3.13. Quite a few packages do not yet have binary release for 3.13, it's quite new.
This is my requirements.txt
So switch to python 3.12?
Could be a good idea.
You don't need to uninstall 3.13, just instal 3.12. py can pick whichever you like.
Okay i switched to python 3.12.8 and ran the "py - pip install -r requirements.txt"
You'll need to say py -3.12 -m pip etc. I'm sure there's a way to select the default Python version.
Oh, excellent.
You have a requirements file with all versions locked, that usually works best on a specific Python version, yes.
Also, that requirements.txt file specifies opencv-python==4.8.0.76. You may need to relax that to just opencv-python (no version) if you have trouble this time around.
You're still using 3.13.
See?
Collecting numpy (from -r requirements.txt (line 34))
Using cached numpy-2.2.1-cp313-cp313t-win_amd64.whl.metadata (60 kB)
Collecting opencv-python==4.8.0.76 (from -r requirements.txt (line 35))
Using cached opencv-python-4.8.0.76.tar.gz (92.1 MB)
That cp313 is the giveaway.
So try:
py -3.12 -m pip install --prefer-binary -r requirements.txt
I think py -0 recites the versions and probably indicates the default one.
This is for that command
https://paste.pythondiscord.com/GRGQ
That... looks better.
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main> py main.py
Traceback (most recent call last):
File "C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main\main.py", line 1, in <module>
from commands.rcon import GameServer
File "C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main\commands\rcon.py", line 1, in <module>
from import_lib import *
File "C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main\import_lib.py", line 6, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main>
Im still getting this error though for py main.py
Ok, also hand add discord and aiohttp
so run these 2 commands?
Py -3.12 -m pip install --prefer-binary discord.py
py -3.12 -m pip install --prefer-binary aiohttp
Looks right.
And you may want to then run your program as py -3.12 main.py
There must be a way to switch py's default Python.....
Until we figure out how to tell py to use 3.12 by default, yes.
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main> py -3.12 main.py
Traceback (most recent call last):
File "C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main\main.py", line 1, in <module>
from commands.rcon import GameServer
File "C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main\commands\rcon.py", line 1, in <module>
from import_lib import *
File "C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main\import_lib.py", line 14, in <module>
from rcon.source import Client
ModuleNotFoundError: No module named 'rcon'
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main>
This is what i got
Sounds like you need rcon also.
You may need to iterate a bit here for missing packages.
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main> py -3.12 -m pip install --prefer-binary rcon
Defaulting to user installation because normal site-packages is not writeable
Collecting rcon
Downloading rcon-2.4.9-py3-none-any.whl.metadata (2.7 kB)
Downloading rcon-2.4.9-py3-none-any.whl (31 kB)
Installing collected packages: rcon
WARNING: The scripts rconclt.exe, rcongui.exe and rconshell.exe are installed in 'C:\Users\kdubw\AppData\Roaming\Python\Python312\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed rcon-2.4.9
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main>
PS C:\Users\kdubw\OneDrive\Documents\The Great Animal\AnimaliaSurvival-Bot-main\AnimaliaSurvival-Bot-main> py -3.12 main.py
addadmin.py could not be loaded. [Extension 'commands.addadmin' raised an error: ValueError: invalid literal for int() with base 10: '']
addcoins.py could not be loaded. [Extension 'commands.addcoins' raised an error: ValueError: invalid literal for int() with base 10: '']
admininject.py could not be loaded. [Extension 'commands.admininject' raised an error: ValueError: invalid literal for int() with base 10: '']
annoucement.py could not be loaded. [Extension 'commands.annoucement' raised an error: ValueError: invalid literal for int() with base 10: '']
ban.py could not be loaded. [Extension 'commands.ban' raised an error: ValueError: invalid literal for int() with base 10: '']
banlist.py could not be loaded. [Extension 'commands.banlist' raised an error: ValueError: invalid literal for int() with base 10: '']
buy loaded successfully!
Cage loaded successfully!
Clearcage.py could not be loaded. [Extension 'commands.clearcage' raised an error: ValueError: invalid literal for int() with base 10: '']
coins loaded successfully!
Collect.py could not be loaded. [Extension 'commands.collect' raised an error: ValueError: invalid literal for int() with base 10: '']
help loaded successfully!
Id.py could not be loaded. [Extension 'commands.id' raised an error: ValueError: invalid literal for int() with base 10: '']
inject loaded successfully!
Kick.py could not be loaded. [Extension 'commands.kick' raised an error: ValueError: invalid literal for int() with base 10: '']
link loaded successfully!
Pay loaded successfully!
Ping loaded successfully!
Question loaded successfully!
Rcon loaded successfully!
Removeadmin.py could not be loaded. [Extension 'commands.removeadmin' raised an error: ValueError: invalid literal for int() with base 10: '']
removecoins.py could not be loaded. [Extension 'commands.removecoins' raised an error: ValueError: invalid literal for int() with base 10: '']
roulette.py could not be loaded. [Extension 'commands.roulette' raised an error: ValueError: invalid literal for int() with base 10: '']
server loaded successfully!
Shop loaded successfully!
Strike.py could not be loaded. [Extension 'commands.strike' raised an error: ValueError: invalid literal for int() with base 10: '']
suggestion loaded successfully!
Tp.py could not be loaded. [Extension 'commands.tp' raised an error: ValueError: invalid literal for int() with base 10: '']
unban.py could not be loaded. [Extension 'commands.unban' raised an error: ValueError: invalid literal for int() with base 10: '']
voicecoins loaded successfully!
Warn.py could not be loaded. [Extension 'commands.warn' raised an error: ValueError: invalid literal for int() with base 10: '']
work loaded successfully!
DEBUG: Waiting for bot to be ready
Bot is Online!
DEBUG: Running check_voice_time loop
Bot presence updated
/help | Players Online: 1
Okay so now how do i get the bot commands to work on discord
Bot is finally online
But the commands do not work
I now don't know. I've never written a discord bot.
Make a new thread (or rename this one) named something like "trouble making my discord bot work", see if you get better help.
Okay thank you i will make a new post
Thank you both so much for the help i appreciate it very much
@upbeat crescent Looks like you can set the PY_PYTHON environment variable to control which Python py invokes by default. Try setting it to 3.12
What commands would i run for that?
I don't use Windows (and thus not py either), so you'll have to ask.
It is no big deal for me to use -3.12 for every command
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.