1

我正在尝试将烧瓶 dotenv 与 python-dotenv 一起使用,但我注意到 Windwos 10 存在问题。

Everyting 在 Mac、Linux 上运行良好,但在 Windows 上运行烧瓶应用程序时出现异常。

似乎问题出在文件上.flaskenv。如果我将文件重命名为.flaskenv_flaskenv则不再有异常,但未定义我的环境变量。我也尝试手动加载此文件,但没有任何成功。未_flaskenv加载。

# .flaskenv
FLASK_APP=manage.py
FLASK_ENV=development
PS D:\practice\flask-dotenv> flask run
Traceback (most recent call last):
  File "C:\Users\popam\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\popam\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\practice\flask-dotenv\venv\Scripts\flask.exe\__main__.py", line 9, in <module>
  File "d:\practice\flask-dotenv\venv\lib\site-packages\flask\cli.py", line 894, in main
    cli.main(args=args, prog_name=name)
  File "d:\practice\flask-dotenv\venv\lib\site-packages\flask\cli.py", line 548, in main
    load_dotenv()
  File "d:\practice\flask-dotenv\venv\lib\site-packages\flask\cli.py", line 608, in load_dotenv
    dotenv.load_dotenv(path)
  File "d:\practice\flask-dotenv\venv\lib\site-packages\dotenv\main.py", line 309, in load_dotenv
    return DotEnv(f, verbose=verbose).set_as_environment_variables(override=override)
  File "d:\practice\flask-dotenv\venv\lib\site-packages\dotenv\main.py", line 138, in set_as_environment_variables
    os.environ[k] = v
  File "C:\Users\popam\AppData\Local\Programs\Python\Python37-32\lib\os.py", line 684, in __setitem__
    self.putenv(key, value)
ValueError: embedded null character```
4

0 回答 0