I'm trying to upgrade some packages and to consolidate my requirements.txt
for an existing python program in order to move it to a docker container.
This container will be based on the tensorflow docker container, this dictates some package versions I have to use. We work under windows and we want to be able to run the program locally on our machines (at least for some time). So I need to find a configuration that works in docker and on Windows 10.
Tensorflow 2.4.1
needs numpy~=1.19.2
. When using numpy 1.20
, pip
complains that numpy 1.20
is an incompatible version.
But when using numpy~=1.19.2
I get the following error when importing cvxpy
. pip
installs all packages just fine:
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "test.py", line 1, in <module>
import cvxpy
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\__init__.py", line 18, in <module>
from cvxpy.atoms import *
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\__init__.py", line 20, in <module>
from cvxpy.atoms.geo_mean import geo_mean
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\geo_mean.py", line 20, in <module>
from cvxpy.utilities.power_tools import (fracify, decompose, approx_error, lower_bound,
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\utilities\power_tools.py", line 18, in <module>
from cvxpy.atoms.affine.reshape import reshape
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\affine\reshape.py", line 18, in <module>
from cvxpy.atoms.affine.hstack import hstack
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\affine\hstack.py", line 18, in <module>
from cvxpy.atoms.affine.affine_atom import AffAtom
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\atoms\affine\affine_atom.py", line 22, in <module>
from cvxpy.cvxcore.python import canonInterface
File "c:\Projekte\algo5\venv\lib\site-packages\cvxpy\cvxcore\python\__init__.py", line 3, in <module>
import _cvxcore
ImportError: numpy.core.multiarray failed to import
Steps to reproduce:
1.)
Create a new Python 3.8 venv
under Windows 10 and activate it
2.) Install the following requirements.txt
via pip install -r requirements.txt
:
cvxpy
numpy~=1.19.2 # tensorflow 2.4.1 requires this version
3.) Execute the following test.py
via python test.py
import cvxpy
if __name__ == '__main__':
pass
The same thing happens if I want to use tensorflow 2.3
. In this case numpy~=1.18
is needed, the error is exactly the same.
Searching for the error finds very few hits which sadly did not help me.
What can I do to solve this?