We have a Flask app “cars-api” to help testers learn to write API automation. One day we hit across this issue while running the app
File “C:/Git/cars-api-master/cars_app.py”, line 234, in
app.run(host=”127.0.0.1″, port=5000)
File “C:\Python27\lib\site-packages\flask\app.py”, line 910, in run
cli.load_dotenv()
File “C:\Python27\lib\site-packages\flask\cli.py”, line 600, in load_dotenv
path = dotenv.find_dotenv(name, usecwd=True)
AttributeError: ‘module’ object has no attribute ‘find_dotenv’
I looked at the issue and was confused since we were not using the dotenv module in our code. One of my colleague Rohan Dudam pointed out that the issue was happening in the recent Flask version which was 1.0.2. The code used to work fine in 0.12.2. I made a temp fix to revert the Flask version to older version.
For a permanent fix, I had a closer look at the error in detail which gave me some idea
File “C:\Python27\lib\site-packages\flask\cli.py”, line 600, in load_dotenv
path = dotenv.find_dotenv(name, usecwd=True)
The cli.py file tries to load find_dotenv method from dotenv. This method was missing from my dotenv file. I upgraded the python-dotenv to a recent version
pip install –upgrade python-dotenv
I changed my Flask version to the recent one and ran the cars_app.py again.
Boom! The cars_app ran swiftly with an upgraded engine 🙂
Note: We run our cars-app in CircleCI container to support our tests for qxf2-page-object-model
This article was produced by Qxf2 Services. Learn more about Qxf2 Services.
I am a dedicated quality assurance professional with a true passion for ensuring product quality and driving efficient testing processes. Throughout my career, I have gained extensive expertise in various testing domains, showcasing my versatility in testing diverse applications such as CRM, Web, Mobile, Database, and Machine Learning-based applications. What sets me apart is my ability to develop robust test scripts, ensure comprehensive test coverage, and efficiently report defects. With experience in managing teams and leading testing-related activities, I foster collaboration and drive efficiency within projects. Proficient in tools like Selenium, Appium, Mechanize, Requests, Postman, Runscope, Gatling, Locust, Jenkins, CircleCI, Docker, and Grafana, I stay up-to-date with the latest advancements in the field to deliver exceptional software products. Outside of work, I find joy and inspiration in sports, maintaining a balanced lifestyle.
Hello All, if this does not work for you. then you can try this —>pip install python-dotenv==0.10.1 (latest version of dotenv)
this helped a lot. thanks so much
Aarav Gotra thanks buddy this version works