r/learnpython • u/Candid-Page1895 • 2d ago
Where should I store user created modules?
Good morning,
I use conda environments with pandas for updating product information and data analysis.
I use Windows 11 and Fedora, but am more often using Windows.
I want to start creating and storing my own modules and packages for ease of use on my own machine for private use.
Is there a dedicated storage location for user created modules as there is for say Powershell 7?
I've asked chatgpt and searched google but a lot of the information is conflicting.
Are there dedicated locations and methods of retrieval depending on OS used?
8
Upvotes
6
u/AlexMTBDude 2d ago
Yeah, it's called "Python Packaging" and here are the docs: https://packaging.python.org/en/latest/
1
u/SleepAffectionate202 1d ago
theres no single default folder you HAVE to use, most people just make a dedicated code directory in their user home folder. if you structure your scripts as a proper package with a pyproject.toml file and do an editable install into your active environment, you can import it from anywhere without messing with system paths.
1
u/Top-Cauliflower-1808 1d ago
There is no single dedicated folder like PowerShell has. Python uses user site packages but that path changes per OS and per conda environment. The cleaner cross-platform habit is one folder you control added to PYTHONPATH on both Windows and Fedora. For code you edit often use pip install -e . into each environment instead of copying files around.
1
u/OlenaDoubleChecks 13h ago
No official spot like Powershell has. Just put your code in a folder, add a pyproject.toml, and pip install -e. into each conda env. Works the same on Windows and Fedora, and no PYTHONPATH hacks.
1
u/ninhaomah 2d ago
Create functions/ classes and import ?
1
u/EnvironmentalDot9131 1d ago
Store them in good place
0
u/danielroseman 1d ago
Python isn't in the business of telling you where to put your modules.
0
u/Longjumping-Boss5708 1d ago
You could store them in a dedicated directory on your server. Alternatively, consider a cloud storage solution if you need scalability or remote access.
0
u/AdhesivenessFew8441 1d ago
To answer the part that confused you: there is a folder like that, it is just per environment. Every Python install (and every conda env) has a site-packages folder that is always on sys.path, and if you drop a plain text file ending in .pth in there with one line containing the path to your own folder (for example C:/Users/you/pymods), everything in that folder becomes importable in that env. Run python -c 'import site; print(site.getsitepackages())' inside the env to see where it lives. There is also a per user one (python -m site --user-site), but it is shared by every env with the same Python version, which gets confusing with conda. Long term, the editable install others mentioned is the cleaner version of the same idea and works the same on Windows and Fedora.