#๐Ÿ”’ Module not found issue

85 messages ยท Page 1 of 1 (latest)

upbeat crescent
#

I have python-dotenv installed but when i type the command py main.py it says module not found and i have tried everything I have seen online, and tried using chatgpt and nothing is working can someone please help it is the last command i need to finish i believe

desert shoreBOT
#

@upbeat crescent

Python help channel opened

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.

upbeat crescent
robust bane
#

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.

upbeat crescent
#

I got the same message

#

It installed but then when i ran command py main.py i got the same modulenotfounderror

#

@robust bane

upbeat crescent
#

I just realized the new error message is discord now not dotenv

#

So do i need to run every module install through py?

robust bane
#

@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

upbeat crescent
robust bane
#

You'll need to show the error.

upbeat crescent
#

Would i be able to run the command "py - pip install -r requirements.txt'?

robust bane
#

Please copy/paste as text, not a screenshot.

upbeat crescent
#

Okay one sec

upbeat crescent
#

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]

agile tiger
upbeat crescent
#

Okay

robust bane
#

!paste
for larger text

desert shoreBOT
#
Pasting large amounts of code

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.

upbeat crescent
#

!paste

agile tiger
upbeat crescent
#

Like that?

robust bane
#

Try py -m pip install --prefer-binary -r requirements.txt

upbeat crescent
#

Running it now

agile tiger
#

Funky one. Latest Python versions removed setuptools, which is the cause of distutils missing.
Please call py -m pip install setuptools

upbeat crescent
agile tiger
#

Though there are later versions of opencv-python that I'm sure alleviate this

#

!pypi opencv-python

desert shoreBOT
upbeat crescent
robust bane
#

Have a look in requirements.txt, line 35. Does it specify this particular version of opencv-python? Because 4.8 is somewhat behind.

upbeat crescent
robust bane
#

Oh, you're using Python 3.13. Quite a few packages do not yet have binary release for 3.13, it's quite new.

upbeat crescent
robust bane
#

You don't need to uninstall 3.13, just instal 3.12. py can pick whichever you like.

upbeat crescent
#

Okay i switched to python 3.12.8 and ran the "py - pip install -r requirements.txt"

robust bane
#

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.

agile tiger
#

You have a requirements file with all versions locked, that usually works best on a specific Python version, yes.

robust bane
#

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
robust bane
#

I think py -0 recites the versions and probably indicates the default one.

robust bane
upbeat crescent
#

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

robust bane
#

Ok, also hand add discord and aiohttp

upbeat crescent
#

so run these 2 commands?
Py -3.12 -m pip install --prefer-binary discord.py
py -3.12 -m pip install --prefer-binary aiohttp

robust bane
#

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.....

upbeat crescent
#

This is what i got from those 2 commands

#

When i run command "py main.py" should i run it as "py -3.12 main.py" instead?

robust bane
upbeat crescent
#

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

robust bane
#

Sounds like you need rcon also.

#

You may need to iterate a bit here for missing packages.

upbeat crescent
#

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

robust bane
#

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.

upbeat crescent
#

Okay thank you i will make a new post

#

Thank you both so much for the help i appreciate it very much

robust bane
#

@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

upbeat crescent
#

What commands would i run for that?

robust bane
#

I don't use Windows (and thus not py either), so you'll have to ask.

upbeat crescent
#

It is no big deal for me to use -3.12 for every command

desert shoreBOT
#
Python help channel closed

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.