[英]python-dotenv is not importing PRIVATE_KEY from .env file
from solcx import compile_standard
import json
from web3 import Web3
import os
from dotenv import load_dotenv
my_address = "0xDFb3e342C0A8F724bfA72e5F2773a12748977f46"
private_key = os.getenv("PRIVATE_KEY")
I am learning solidity and when I use python-dotenv to import my PRIVATE_KEY from a.env file,我正在学习稳定性,当我使用 python-dotenv 从 a.env 文件导入我的 PRIVATE_KEY 时,
export PRIVATE_KEY = 0xd6a5ea3d2c97b1dd03fd1b9c447e36791522135136665f23b0c08c6395f66d7a
it imports it as none and throws an error.它将其导入为 none 并引发错误。 this error I have given the full script that I wrote above.
这个错误我已经给出了我上面写的完整脚本。 I hope someone can help me solve this problem
我希望有人能帮我解决这个问题
Make sure .env
file is in the same directory.确保
.env
文件位于同一目录中。
Calling load_dotenv
will look for .env
file and sets the environment variables调用
load_dotenv
将查找.env
文件并设置环境变量
load_dotenv()
if .env
file is not in the same directory you have to pass the path of.env file to load_dotenv
如果
.env
文件不在同一目录中,则必须将 .env 文件的路径传递给load_dotenv
load_dotenv(path_of_env)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.