简体   繁体   English

.env 文件是正确执行 .py 脚本所必需的,但在我的 AWS Ec2 实例上找不到

[英].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.我已将 .env 文件上传到 AWS EC2 实例,但由于在 Linux 下每个以点开头的文件都不可见的原因,当我使用 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.主要问题是我的 .py 脚本使用了 .env 中的变量,但只要它不可见,似乎就无法“找到”它。 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".我尝试重命名 .env 文件,但后来我不确定如何对其进行编码,以便我的 .py 脚本不是在寻找“.env”而是“test.env”。

I found the solution.我找到了解决方案。

you can target another .env file by using load_dotenv('test.env')您可以使用load_dotenv('test.env')定位另一个 .env 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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