Installing extra modules in PHP 7.3 in Codebuild

0

We are attempting to install an extra module into PHP however getting an error when we enable amazon linux extras:

From the build log:

Running command /usr/bin/amazon-linux-extras enable php7.3 
/usr/local/bin/python: No module named amazon_linux_extras

Relevent section of Buildspec (in the install phase):

    commands:
      - php -v
      - yum -y install amazon-linux-extras yum-utils python-boto
      - /usr/bin/amazon-linux-extras enable php7.3
      - yum install -y php-mcrypt 

What are we missing????

jorgr
질문됨 5년 전1067회 조회
3개 답변
0

Hi jorgr,

We do not add amazon-linux-extras as a module for Python 3. You can copy this module from
Python 2 to Python 3 by using the following command:

cp -r /lib/python2.7/site-packages/amazon_linux_extras /usr/local/lib/python3.7/site-packages

Best,
Zhen

AWS
Zhen Li
답변함 5년 전
0

Correct command to copy the module would be:

cp -r /usr/lib/python2.7/site-packages/amazon_linux_extras /usr/local/python37/lib/python3.7/site-packages
답변함 4년 전
0

As noted in another reply, amazon-linux-extras is only available under python 2. Python 2 is officially sunsetted. Now that python defaults to python3 in Amazon Linux 2, this has broken amazon-linux-extras and AWS should address the issue.

After inspecting the script amazon-linux-extras, I saw that if the variable PYTHON is not defined, it uses python by default. To work around, rather than copying any files, we can simply tell it to use python 2:

PYTHON=python2 amazon-linux-extras enable <package-name>
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠