我有一个main.pyx文件,我将其cythonize,以给予给main.c。我在gitlab CI/CD中构建了这个C文件,并运行它,但它给了我NoModuleFoundError。
~
main.pyx
import numpy as np
..
~
- cythonmain.pyx--embed*
~
.gitlab-ci.yml
stages:
- build
image: python:3.9.16
variables:
HTTP_PROXY: $CODE_PROXY
HTTPS_PROXY: $CODE_PROXY
before_script:
- apt-get clean
- apt-get --allow-unauthenticated update
- apt-get upgrade
- apt-get install -y gcc
- apt-get update
- apt search '^python\[0-9\]\*-dev'
- python3 --version
build-job:
stage: build
script:
- echo "Compiling the code..."
- python3 -m pip install --upgrade pip
- python3 -m venv venv
- source /path/venv/bin/activate
- python3 -m pip install --upgrade pip
- pip install pyimagej
- pip show numpy
- python3 check_py.py
- gcc -v main.c -I /usr/include/python3.9/ -I /usr/include/ -I /usr/local/include -I /usr/local/include/python3.9 -L /usr/lib/python3.9 -lpython3.9 -o main_output
- ./main_output
- echo "Compile complete."
~
我尝试运行CI/CD,但得到以下错误:
Traceback (most recent call last):
File "main.pyx", line 1, in init main
import numpy as np
ModuleNotFoundError: No module named 'numpy'
我希望main_output能顺利运行,但我不确定如何使其工作。如有任何意见,将不胜感激。
1条答案
按热度按时间flmtquvp1#
我必须将pyx文件定向到numpy包的正确位置。
很简单!