Setting up a Python environment to point to a modules directory on a Mac

34 Views Asked by At

I'm trying to set up a local development environment for Python. We use BitBucket for source control of Python modules we've developed for our company. On my machine I have this folder/directory set up:

~/xxxxxxx/Development/Git/xxxxxx/modules/

This serves as my local repo for the BitBucket repo.

In my .zshrc file I pointed $PYTHONPATH to this directory:

export PYTHONPATH="~/Desktop/xxxxxx/Development/Git/xxxxxxx/modules/"

In Terminal, when I put in this command: echo $PYTHONPATH I get what I expect:

 xxxxxxxxxxx@Steves-MacBook-Pro ~ % echo $PYTHONPATH
~/Desktop/xxxxxx/Development/Git/xxxxxx/modules/

I then wrote this short script:

import os
import datetime
import json
from jira import JIRA
from jira.client import ResultList
from jira.resources import Issue
import importlib

# import modules from relative paths
colors = importlib.import_module('modules.colors')
mondayManager = importlib.import_module('modules.mondayManager')
jiraManager = importlib.import_module('modules.jiraManager')
appManager = importlib.import_module('modules.appManager')

###############################
# APP STARTS HERE             #
###############################

if __name__ == '__main__':

    print("What's up dude?")

I get an error on the first import:

ModuleNotFoundError: No module named 'modules'

I am obviously doing something wrong or misunderstanding how this is suppose to function, any help would be appreciated.

0

There are 0 best solutions below