Suppose I have 2 Python project folders. Folder 1 is called module2 and located at /Users/jianxiongwu/Documents/Python/Github/module2 inside folder1 there is a python file called test.py containing the below code. When I run the code below I activated the local environment first with source env/bin/activate
import sys
sys.path.append('/Users/jianxiongwu/Documents/Python/Github/testPDF')
import module1
module1.test1()
The second Python project folder is located at /Users/jianxiongwu/Documents/Python/Github/testPDF containing module1.py with below lines:
def test1():
print('test from module 1')%
When I do sys.path.append I can import module1. I want to get rid of this line and use PYTHONPATH instead on my MAC OS ver. 12.1. I then edited the bash_profile by including "/Users/jianxiongwu/Documents/Python/Github/testPDF" in PYTHONPATH. After commenting the sys.path.append('/Users/jianxiongwu/Documents/Python/Github/testPDF') I get an module not found error.
cat ~/.bash_profile
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
#Setting path to the POS
export PYTHONPATH=["/Users/jianxiongwu/Documents/Python/Github/POS/env/lib/python3.7/site-packages",
"/Users/jianxiongwu/Documents/Python/Github/testPDF"]
export PATH="/usr/local/opt/mysql-client/bin:$PATH"