Basic knowledge of deep learning (based on Tensorflow implementation)
In order to install and deploy the project code correctly, we need to configure the source
folder of this project. The following are configuration schemes for different usage scenarios.
-
Using in a
*.py
scriptWe need to set the
$PYTHONPATH
environment variable in system, suppose/path
is your parent path of foldersource
(i.e./path/source
), then add the new line to the end of your system file~/.bashrc
or~/.zshrc
:export PYTHONPATH=/path:$PYTHONPATH
Save the file and exit the text editor. Restart your terminal or run
source ~/.bashrc
(orsource ~/.zshrc
if you're using Zsh) to apply the changes to your current terminal session.Now, you can import and use the
source
package of this project like other Python packages in any*.py
script or in ternimal.from source.code import utils
-
Using in a
*.ipynb
Jupyter Notebook in Web browser -
Using in a
*.ipynb
Jupyter Notebook in VSCode -
General Solution
A common solution is to add the parent path to the
source
package throughsys.path.append
before running other code whether you are writing*.py
scripts or using Jupyter Notebook.import sys sys.path.append("your parent path of source")
The disadvantage of this method is that it is temporary and must be performed every time you write a new project.