Forums

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

pipeline python: ModuleNotFoundError

Frank Hsu March 29, 2018

I want to check my pyd python module. So, my test.py will import my pyd module.

But can't set PYTHONPATH correct to import this module successfully.

 

+ umask 000

+ GIT_LFS_SKIP_SMUDGE=1 git clone --branch="pipeline" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/ihshsu/pygrlib.git $BUILD_DIR ; git reset --hard 18d6bf0630c0c64639e7498567e8109eb3ccfd20 ; git remote set-url origin git@bitbucket.org:ihshsu/pygrlib.git
Cloning into '/opt/atlassian/pipelines/agent/build'...
HEAD is now at 18d6bf0 bitbucket-pipelines.yml edited online with Bitbucket

+ chmod 777 $BUILD_DIR

Cache "pip": Downloading
Cache "pip": Not found
+ python --version
Python 3.6.3

+ cd ./pyGRLib

+ export PYTHONPATH=.

+ python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pyGRLib
ModuleNotFoundError: No module named 'pyGRLib'

Skipping cache upload for failed step
Searching for test report files in directories named [test-results, failsafe-reports, test-reports, surefire-reports] down to a depth of 4
Finished scanning for test reports. Found 0 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.

2 answers

0 votes
Frank Hsu March 30, 2018
export PYTHONPATH=${PYTHONPATH}:/opt/atlassian/pipelines/agent/build:/opt/atlassian/pipelines/agent/build/pyGRlib

this path can work. But .pyd can't be used. Any suggestion ? 

0 votes
Edwin Kyalangalilwa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2018

Hi Frank,

Is there another directory called pyGRLib under pyGRLib?

+ cd ./pyGRLib

 If not then place your script in the same directory as pyGRLib. From here it should import.

pyGRLib test.py
Frank Hsu March 30, 2018

My module name is pyGRLib.pyd. And test.py will call "import pyGRLib".

But I don't know how to set PYTHONPATH in pipeline environment. I try sys.path.append in test.py but still not work. Any suggestion ?

Frank Hsu March 30, 2018

There is no problem if dos command line to run below:

cd pyGRLib
set PYTHONPATH=.
python test.py

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events