在使用cookiecutter安装fastapi的web项目模板时,发生报错,网上没有太多相关的记录,故记录下解决方法
安装过程:
-
安装cookiecutter包
pip install cookiecutter
-
获取fastapi模板
cookiecutter https://github.com/tiangolo/full-stack-fastapi-postgresql
安装失败,报错如下:Traceback (most recent call last): File "D:\project\anaconda\envs\speak_test\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\project\anaconda\envs\speak_test\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "D:\project\anaconda\envs\speak_test\Scripts\cookiecutter.exe\__main__.py", line 7, in <module> File "D:\project\anaconda\envs\speak_test\lib\site-packages\click\core.py", line 829, in __call__ return self.main(*args, **kwargs) File "D:\project\anaconda\envs\speak_test\lib\site-packages\click\core.py", line 782, in main rv = self.invoke(ctx) File "D:\project\anaconda\envs\speak_test\lib\site-packages\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "D:\project\anaconda\envs\speak_test\lib\site-packages\click\core.py", line 610, in invoke return callback(*args, **kwargs) File "D:\project\anaconda\envs\speak_test\lib\site-packages\cookiecutter\cli.py", line 140, in main cookiecutter( File "D:\project\anaconda\envs\speak_test\lib\site-packages\cookiecutter\main.py", line 67, in cookiecutter repo_dir, cleanup = determine_repo_dir( File "D:\project\anaconda\envs\speak_test\lib\site-packages\cookiecutter\repository.py", line 110, in determine_repo_dir cloned_repo = clone( File "D:\project\anaconda\envs\speak_test\lib\site-packages\cookiecutter\vcs.py", line 101, in clone subprocess.check_output( File "D:\project\anaconda\envs\speak_test\lib\subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "D:\project\anaconda\envs\speak_test\lib\subprocess.py", line 524, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['git', 'clone', 'https://github.com/tiangolo/full-stack-fastapi-postgresql']' returned non-zero exit status 128.
-
修改cookiecutter的源代码,不让它退出,找到出错的原因
File "D:\project\anaconda\envs\speak_test\lib\subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
修改该句,把check=True改为ckeck=False -
再次执行
cookiecutter https://github.com/tiangolo/full-stack-fastapi-postgresql
报错如下:A valid repository for "https://github.com/tiangolo/full-stack-fastapi-postgresql" could not be found in the following locations: C:\Users\fortune\.cookiecutters\full-stack-fastapi-postgresql
-
到git网站上下载包,然后手动替换
解压并放到指定路径,记得修改文件名
这里我解压到C:\Users\fortune.cookiecutters\full-stack-fastapi-postgresql,文件夹名称是full-stack-fastapi-postgresql
-
执行
cookiecutter https://github.com/tiangolo/full-stack-fastapi-postgresql
You've downloaded C:\Users\fortune\.cookiecutters\full-stack-fastapi-postgresql before. Is it okay to delete and re-download it?
该选项选择no
Do you want to re-use the existing version? [yes]: yes
选择yes
随后都是配置项了
初始化项目时需要用到的openssl模块,可以参考
openssl安装教程的第二种方法,下载exe文件后直接安装并配置好环境变量,最后使用openssl rand -hex 32
命令获取一个key用作secret_key和password。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)