I've got a PyCharm "project" in Python, which is to say that I have a folder that is a conglomeration of all sorts of experimental python files, convenience methods/classes, and Jupyter notebooks from following along with online classes.
I've actually just written something that I'm proud of and would like to re-use. I'm finding it difficult to import. I have looked at and attempted implementing the answers to the following questions to no avail:
- Can't import my own modules in Python
- How to import my own modules in python 3.6?
- How to import my own modules the elegant way?
Project structure:
learning_project
|
├───.idea
│ ├───dictionaries
│ └───inspectionProfiles
|
├───decision_trees
├───linear_algebra
├───neural_networks
| ├───based_sequential.py <---------------------------- # Module location #
│ ├───cross-entropy-gradient-descent
│ └───learning pytorch
| ├─── class_notebook.ipynb <---------------------- # Want to import for use here #
| └───Cat_Dog_data
|
└───venv
├───Include
├───Lib
│ └───site-packages
└───Scripts
I have tried the following:
import based_sequential
from based_sequential import ClassName
import based_sequential.ClassName
import neural_networks
from neural_networks import based_sequential
import neural_networks.based_sequential
from neural_networks.based_sequential import ClassName
All result in the error No module named '<pick your poison>'
- Question 1: Obviously, what am I missing?
- Question 2: Is my organization here part of the problem? I'm starting to suspect that it is.
I also suspect I have some work to do learning the administrative aspects of writing code that is bigger than just one .py file.