The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

"Module Not found" error when trying to access modules from my repo from Bitbucket pipeline

Saranya Devi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2023
  • My bitbucket-pipeline.yml file is as follows:

image: python:3.9pipelines:
branches:
master:
- step:
script:
- pip install requirements.txt
- python $BITBUCKET_CLONE_DIR/Folder3/Sub Folder 1/run-test.py

 It is building Python docker and installing all the requirements. 

Issue is when it's trying to access a module in my repo while running tests.

Repo structure is like,

Repo_name:

          -Folder 1

          -Folder 2

          -Folder 3

                 -Sub Folder 1

                           -run-test.py

So whenever run-test.py file tries to access or import Folder1 or Folder 2, I am getting Module not found error. 

I am using $BITBUCKET_CLONE_DIR variable also before run-test.py file, so that it will identify the path.

I could see that it's cloning the repo to BITBUCKET_CLONE_DIR path

Is there any way to set the path in pipelines.yml file so that it would find path for all files and work.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2023

G'day and welcome to the community @Saranya Devi 

Have you looked into using the sys path in your script to set the path file manually?

Because by default, the Python interpreter will check for the file in the current directory only, and we need to set the file path manually to import the modules from another directory.

There is various way of doing these; please check the following suggested workaround:

 Import Python module from different directory 

Cheers,
Syahrul

TAGS
AUG Leaders

Atlassian Community Events