#๐Ÿ”’ Fixing files and import

35 messages ยท Page 1 of 1 (latest)

keen elmBOT
#

@south osprey

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.

south osprey
#

how can I show my code here

silk whale
#

!paste

keen elmBOT
#
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.

south osprey
#

I've done my IMS.PY but I'm having problems with my MAIN.PY, cuz it doesnt run

dry mango
#

send the code

south osprey
silk whale
#

Do you get any errors?

south osprey
#

that's my IMS.PY, and it works fine but I'm having problem with my other code that should work alongside it

silk whale
#

What problem are you having?

#

Are you running main.py? If so, you need to call the main function

south osprey
#

it says something like "No module named "IMS" "

silk whale
#

What's your file structure

south osprey
#

there are 2 main components, a module named IMS ( contains functions for inventory management, such as loading inventory, displaying the menu, adding, viewing, deleting, restocking chemicals, executing experiments, and saving inventory) and a main script (imports functions from IMS.py to manage the inventory.)

silk whale
#

Yes, where are they located in relation to each other: same folder, etc?

south osprey
#

i didnt put them in the same folder, but there are just within my desktop, is that wrong?

#

i didnt put them in any folder at all

silk whale
#

Ok, so they are both just in the Desktop, neither of them is in any folder?

south osprey
#

i've just place both of them in a folder, rn. but its still not working

silk whale
#

Just to be clear, the same folder, right?

south osprey
#

yes

#

"No such file or directory"

silk whale
#

Python is probably not looking in the current directory for some reason, but just to be sure, try renaming IMS.PY to ims.py, and using import ims

south osprey
#

on it

silk whale
#

Oh wait

south osprey
#

i'm not really well versed with python so I don't really know what im missing there

silk whale
#

The way python looks for modules when you import them can be kinda funky

silk whale
oak breach
#

Cmd?

south osprey
#

i tried running them from the same folder but it still doesnt work

silk whale
#

Ask in general chat, there's probably something I'm missing

keen elmBOT
#
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.