Friday, January 26, 2024

Fix Python packages imports not found




 I have started working with Python and Apache-Airflow in a data engineering project. But one I run the code, I had this error:


In the  same time, the packages airflow presents an issue and seems not found. hmmm.


Checking the Apache-airflow under python\site-packages, the dependencies are available.


Checking further, I found that Visual studio code is using the version 3.7.7, while my terminal is pointing to a newer version (3.12).This happened when I have updated Python, and added it to the environment variables, but not on Visual Studio.

Environment variables Python

So what happens in that when I install the packages, it's available in the newer version, but not found in Visual studio as the older Python version doesn't contain the requested package.

In order to fix that, on visual studio, get the Python interpreter:

ctrl + shift + p then type: Python: select interpreter




 

 

Puython data engineer apache airflow

 Then select the Python version your environment variable is pointing.

Python data engineer apache airflow

That's all 😉.





Thursday, January 18, 2024

Fix AWS Elastic BeansTalk Roles Error

AWS Elastic Beanstalk is a service provided by Amazon Cloud in order to deploy and manage web application in a simple way. This post focus on an error that you can get when you try to create for the first time a beanstalk application and environment (dev, staging, production.


AWS Elastic Beanstalk


When working with Elastic Beanstalk, it's possible to have this error "aws-elasticbeanstalk-ec2-role doesn't exists when creating the environment". This is due to the fact that Amazon is no more creating the role and it should be manually added.

When creating an environment to run the application on EC2 instances, 2 roles are required. 

aws-elasticbeanstalk-service-role:

- AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy 

- AWSElasticBeanstalkEnhancedHealth

aws-elasticbeanstalk-ec2-role:

- AWSElasticBeanstalkWebTier 

- AWSElasticBeanstalkWorkerTier

- AWSElasticBeanstalkMulticontainerDocker


so in order to fix the errors "No Environment found for EnvironmentName" and "aws-elasticbeanstalk-ec2-role doesn't exists when creating the environment", you should add the new rol in the IAM roles. To do so:

    - Open IAM console

    - Choose Roles and create a new Role

    - Choose "AWS Service" as  a trusted entity

    - For the use Case, use EC2

    - Attach AWSElasticBeanstalkWebTier, AWSElasticBeanstalkWorkerTier, and AWSElasticBeanstalkMulticontainerDocker.

    - Last, don't forget to create the Environment using the already created role for EC2.


AWS Beanstalk Role

Articles les plus consultés