#๐ how to work with making multiple modules
41 messages ยท Page 1 of 1 (latest)
@dull temple
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.
If firstmodule is the name of your module, inside a python file
Say, for example, the python file is named first_module_file.py
from your other file, you would do
from first_module_file import firstmodule
You can then use firstmodule normally
bare in mind, when importing from a file using import and/or from you leave out the file extension. Hope that helps
thank you, the thing is those are separate modules
I do know how to import from a folder nearby that has a __init__.py file
Two separate modules in the same file or different files?
They probably have 2 folders as modules
yeah
like 2 separate libraries
You can add it to your python PATH variable
import sys
sys.path.insert(1, '/path/to/application/app/folder')
I'm pretty sure you can pip install path/to/local/module, or pip install -e path/to/local/module to install it in editable/development mode, the latter is probably what you want if you're still devving it on your system
Basically this adds /path/to/application/app/folder to the list of folders for the python interpreter to search from when using the import module
That's actually cool, I never knew that
To set it up correctly easier, look into setuptools or smthn
thanks, that sounds exactly like what I need
I need to somehow make the first module importable
what do you mean by that
Just wanted to be able to say import mymodule
If I want to share it with other people I can't use sys.path.insert because they will have different paths
everywhere? or for one specific project
everywhere
oh yes if you specifically want to share your code you want to look up how to distribute a python package
pip install -e does that
well I want to share it but the question is more about how do I develop 2 packages when one depends on another
you want to share both of them? what do they dfo
the code in the other package needs to work as if the first package was installed
packages can have requirements for others
python packaging can be slightly in the weeds, i know arjancodes usually does excellent videos
It can be tricky when different packages in Python don't play nice. The solution to this problem is to create an isolated, virtual environment. In this video, Iโll show you how to set up a virtual environment with poetry, a package manager for Python that simplifies dependency management and project packaging.
๐ Next-Level Python Skillshare Cla...
Do you want to know how to build a complete Python package? Well, look no further! This video will take you step-by-step through the entire process, from creating your project to publishing it on PyPI.
The most popular software licenses available: https://tldrlegal.com/ or https://choosealicense.com/
Check the available classifiers here https...
first one is a bunch of tensor transforms that arent in torchvision transforms or anywhere else, and second one is for quickly making datasets or merging datasets but basically it needs the first one to compose transforms
yes eventually you'd want to do pip install -e in the second one while you are developing it
i suggest check out both of those videos, and come back and ask more questions if there's new things you are still confused about
ok, thanks!
I've just realized that to pip install my package I probably need to do something with it to make it being able to install using pip, but I am sure that one is googleable
yes the second video will explain that ๐
!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.