简体   繁体   中英

.env file is required for executing a .py script properly but is not found on my AWS Ec2 instance

I have uploaded the .env file to the AWS EC2 instance but due to the reason that under Linux every file that starts with a dot is made invisible it is not listed when I use ls. The main problem is that my .py script uses variables from the .env but can't seem to "find" it as long as it is invisible. I tried renaming the .env file but then I am not sure how to code it so that my .py script is not looking for ".env" but "test.env".

I found the solution.

you can target another .env file by using load_dotenv('test.env')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM