Search code examples
pythonpython-importenvironmentpythonpath

Have already set PYTHONPATH, but why it cant able to import my custom modules in Python?


The following is my 'env' in my mac via Terminal enter image description here

And I have already add my workspace path with PYTHONPATH in file ~/.bash_profile like below:

Since I want to import some custom functions which written by myself, here is the custom function bath: /Users/LSH/WSFG_DEV/workspace/ws_functions (But I think it's better to include the whole workspace) enter image description here

So weird that although it says no module named 'ws_functions', but the VSC still can address my custom functions (etc: send_IFTTT_notice_rich / send_IFTTT_notice_simple...)

enter image description here

May I know what kind of things I am still missing?

Update @ 25 July : So weird that I cant even print the PYTHONPATH with os module... enter image description here


Solution

  • You're not running in a bash login shell, so ~/.bash_profile doesn't do anything. In fact, you're not even using bash, so ~/.bash_profile doesn't do anything. Try setting PYTHONPATH in ~/.zshrc.