#๐ Paths
50 messages ยท Page 1 of 1 (latest)
@muted walrus
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.
from Project import config
and if in name of project i have spaces like: Project X?
you cant by doing simple thing
but you can still use the lib importlib
i renamed project, it doesnt work
from project import example doesnt work ?
ye
from project import config*
show me ur tree
Rina Disnake its just name of project, i renamed it too now
you put congif and not config
that might be why
In Leave.py add the following to the top of the file. This will tell the python interpreter where to look for the file. In the append function use the actual path of the parent directory
import sys
sys.path.append('C:\Users\zay...\Rina')
import config
oh ๐ณ but anyway it doesnt matter
and if i will change my pc i will need to change all my files ๐คจ
I would recommend using pathlib
if __name__ == '__main__':
import sys
import pathlib
sys.path.append(pathlib.Path().absolute().parent.as_posix())
this will relatively locate the path of Rina(project root) when that file is directly runned
Also look into using python modules with init.py that might that right way to do it. I'm pretty new to python myself.
it have to be a module to make it possible (or otherwise very diffcult if not impossible)
uhm.. what means last
it mean
append a path that is the parent of the current working directory to sys.path in string format
sys.path is a list of path that python will look through to import module
okey i will try it
why it can happens
I tried that and I think you will still need to add the name of your project to the end. Like this.
sys.path.append(pathlib.Path().absolute().parent.as_posix()+"/Rina")
it returns error
bcs of +
what about this?
import sys
import pathlib
path = pathlib.Path().absolute().parent.as_posix()+"/Rina"
sys.path.append(path)
returns Rina folder
your config import should work now
from path import config?
no just
import config
You cannot print a append, list.append return None
Instead you should just print the content
For debug purposes
thank you very much, it works fine now
and deleted.user0 thank you too! ๐ค
YW!
!close
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.