Pipenv 安装锁定失败!没有名为“json"的模块 [英] Pipenv install Locking Failed!No module named 'json'

查看:44
本文介绍了Pipenv 安装锁定失败!没有名为“json"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在清理我的电脑.我删除了 vstudio2017.

I am cleaning my computer recently.I deleted vstudio2017.

现在我的环境

python3.6,win10

奇怪的事情发生了,pipenv好像完全失效了.

Strange things have happened,pipenv seems to be completely invalid.

PS F:\hankspace\flaskproject> pipenv install
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Locking Failed!
Traceback (most recent call last):
  File "c:/users/hank/appdata/local/programs/python/python37/lib/site-packages/pipenv/resolver.py", line 3, in <module>
    import json
ModuleNotFoundError: No module named 'json'
File "c:/users/hank/appdata/local/programs/python/python37/lib/site-packages/pipenv/resolver.py", line 3, in <module>
    import json
ModuleNotFoundError: No module named 'json'

我删除了 python3.6 和 pipenv,另外重新加载了 python3.7 和 pipenv.但他们有同样的问题.

I deleted python3.6 and pipenv in addition reload python3.7 and pipenv. but they have same problem.

PS F:\hankspace\flaskproject> pipenv graph

ERROR:  Traceback (most recent call last):
  File "c:\\users\\hank\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\pipenv\\vendor\\pipdeptree.py", line 6, in <module>
    import argparse
ModuleNotFoundError: No module named 'argparse'

我列出了我提交的尝试.

I listed what I filed tried.

  • $ pip install --user pipenv
  • 删除点重新加载点
  • 导出路径

这是一个看起来很像我的例子.Python看到json 模块,但 pipenv 没有.为什么?

Here is a example that looks a lot like me.Python sees json module but pipenv doesn't. Why?

我猜他可能已经解决了这个问题,但我没有足够的声誉来发表评论.如果有人能给我一些建议,我将不胜感激.

I guess he may have solved the problem but I’m no enought reputation to comment. I will be grateful if someone can give me some advice.

推荐答案

为我修复的是将以下内容添加到我的系统环境变量中:

What fixed it for me was adding the following to my system environment variables:

在 Windows 中:

In Windows:

setx /M PIPENV_VENV_IN_PROJECT 1

这将强制 pipenv 在您的项目文件夹中创建一个.venv"目录,而不是您的用户配置文件目录中的默认virtualenvs"(这部分是破坏pipenv install"的原因).它还将为您提供正确的.venv"目录和文件结构,对应于 pipenv 创建它的方式,而不是python -m venv .venv"创建它的方式.据我所知,结构是不同的.

This will force pipenv to create a ".venv" directory in your project folder instead of the default "virtualenvs" in your user profile directory (this part is what is breaking "pipenv install"). It will also give you the proper ".venv" directory and file structure that corresponds to the way pipenv creates it instead of the way "python -m venv .venv" creates it. From what I've seen, the structures are different.

可以在以下 URL 中找到有关此问题的更多信息:https://github.com/pypa/pipenv/issues/1382

More information about this issue can be found at the following URL: https://github.com/pypa/pipenv/issues/1382

如果您想在 Linux 中获得相同的结果,请使用以下命令设置变量:

If you want this same result in Linux, set the variable with the following command:

export PIPENV_VENV_IN_PROJECT=1

这篇关于Pipenv 安装锁定失败!没有名为“json"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆