我有一个 我项目中的.env文件
SECRET_KEY="vvvvvvvtestvvvvv"
我运行pipenv shell
但是我会遇到很多错误。
PS S:\github\fozvi> pipenv shell
Loading .env environment variables…
Traceback (most recent call last):
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Sander-PC\AppData\Local\Programs\Python\Python37\Scripts\pipenv.exe\__main__.py", line 9, in <module>
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\cli\command.py", line 381, in shell
load_dot_env()
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\core.py", line 172, in load_dot_env
dotenv.load_dotenv(dotenv_file, override=True)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\dotenv\main.py", line 262, in load_dotenv
return DotEnv(f, verbose=verbose).set_as_environment_variables(override=override)
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\dotenv\main.py", line 105, in set_as_environment_variables
os.environ[k] = v
File "c:\users\sander-pc\appdata\local\programs\python\python37\lib\os.py", line 684, in __setitem__
self.putenv(key, value)
ValueError: embedded null character
我在做什么错了?
答案 0 :(得分:1)
只是遇到了这个问题。可能是文件编码问题。
尝试在Notepad ++中打开.env文件,将编码更改为UTF-8,然后保存该文件,然后重试。
答案 1 :(得分:0)
您的SECRET_KEY
可能在某处包含\0
,并且环境变量中不能包含NUL字节。只需将其从环境文件中的SECRET_KEY
中删除,它便可以正常工作。