1. Add environment variables to Pythonpath
Export pythonpath= $PYTHONPATH:/home/myproject
View Pythonpath
Echo $PYTHONPATH
You can enter the Python interpreter and print the Sys.path proof to take effect.
After adding an environment variable, this is done in a deep-rooted python file that can be run independently of the project
such as myproject/a/b/c.py
2, if not add the environment variable, directly into the myproject/a/b/file, and then run c.py is not to run, because c.py often refer to a lot of other modules, Python is not automatically put the parent folder Grandfather folder also added to Pythonpath, PYCAHRM can directly right-click to run the reason is to automatically add additional environment variables, the project folder to add to the environment variable.
3, if not add environment variables, directly run myproject/run.py is no problem, here run is directly below the MyProject, because Python automatically added this folder to the environment variable, but does not automatically add the parent grandfather to the environment variable, so Myproject/a/b/c.py is not functioning properly.
4, If you do not add the environment variables and directly run myproject/a/b/c.py, then the method is to use PYTHON-M, PYTHON-M General introduction is directly run the three-party library inside the file, in fact, can be used to run their own written things. Use the method is to go to the MyProject folder, and then Python-m A.B.C will be able to run normally.
This method is good, the environment variable should not be too much, too much, may cause the Python file with the same name to cause conflict.
Linux Add pythonpath environment variable