Forums

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

Bitbucket: ModuleNotFoundError: No module named 'numpy'

stefanoc May 6, 2021

I'm trying to setup unit tests in Bitbucket using the following bitbucket-pipelines.yml

image: python:3.7.3

pipelines:
  default:
    - step:
      caches:
        - pip
      script: # Modify the commands below to build your repository.
        - pip3 install --upgrade pip setuptools wheel
        - pip3 install -r requirements.txt
    - step:
      script:
        - python3 -m unittest discover -vp 'Test*.py'

The file requirements.txt is the following:

tensorflow==2.4.1
Keras==2.4.3
pandas==1.1.3
requests==2.24.0
matplotlib==3.3.2
numpy==1.19.2

numpy is present in the requirements but when it runs the unit tests, I get the following error:

  import numpy as np
ModuleNotFoundError: No module named 'numpy'

 

1 answer

1 vote
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 7, 2021

@stefanoc this means , that when you install dependencies, they failed to install. The possible reason is that you freeze version, and some package, for example, pandas, require numpy of another version, BUT you have a conflict here.

Try to install it locally and ensure you have latest pip package manager, they recently did very major update that shows this error, I explained above.

While installing locally, you will see the error or will manually check if the package is installed indeed.

I just tried to install you requirements and got:

```(.venv) ➜ my-dir ✗ pip install -r requirements.txt
ERROR: Could not find a version that satisfies the requirement tensorflow==2.4.1
ERROR: No matching distribution found for tensorflow==2.4.1

```

So pay attention to this and ensure you have python and pip of required version

Regards, Galyna

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events