django - 试图将 django 安装到我的虚拟环境中

标签 django linux ubuntu pipenv

我是 linux 和 pipenv 的新手。我尝试使用“pipenv install django”在我的新环境中安装 django,这发生了:

Installing django…
Adding django to Pipfile's [packages]…
✔ Installation Succeeded 
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success! 
Updated Pipfile.lock (4f9dd2)!
Installing dependencies from Pipfile.lock (4f9dd2)…
An error occurred while installing asgiref==3.2.5 --hash=sha256:3e4192eaec0758b99722f0b0666d5fbfaa713054d92e8de5b58ba84ec5ce696f --hash=sha256:c8f49dd3b42edcc51d09dd2eea8a92b3cfc987ff7e6486be734b4d0cbfd5d315! Will try again.
An error occurred while installing django==3.0.4 --hash=sha256:50b781f6cbeb98f673aa76ed8e572a019a45e52bdd4ad09001072dfd91ab07c8 --hash=sha256:89e451bfbb815280b137e33e454ddd56481fdaa6334054e6e031041ee1eda360! Will try again.
An error occurred while installing pytz==2019.3 --hash=sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d --hash=sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be! Will try again.
An error occurred while installing sqlparse==0.3.1 --hash=sha256:022fb9c87b524d1f7862b3037e541f68597a730a8843245c349fc93e1643dc4e --hash=sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548! Will try again.
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 4/4 — 00:00:00
Installing initially failed dependencies…
  ☤  ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 4/4 — 00:00:00
[pipenv.exceptions.InstallError]:   File "/home/codrut/.local/lib/python3.7/site-packages/pipenv/cli/command.py", line 254, in install
[pipenv.exceptions.InstallError]:       editable_packages=state.installstate.editables,
[pipenv.exceptions.InstallError]:   File "/home/codrut/.local/lib/python3.7/site-packages/pipenv/core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]:       skip_lock=skip_lock,
[pipenv.exceptions.InstallError]:   File "/home/codrut/.local/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "/home/codrut/.local/lib/python3.7/site-packages/pipenv/core.py", line 862, in do_install_dependencies
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, False, failed_deps_queue, retry=False)
[pipenv.exceptions.InstallError]:   File "/home/codrut/.local/lib/python3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: []
[pipenv.exceptions.InstallError]: ['Traceback (most recent call last):', '  File "/home/codrut/.local/share/virtualenvs/Django-B9r4LqTh/bin/pip", line 5, in <module>', '    from pip._internal.cli.main import main', "ModuleNotFoundError: No module named 'pip'"]
ERROR: ERROR: Package installation failed...

提到几分钟前我在错误的文件夹上安装了 django 并且一切正常..
请帮忙!谢谢!

最佳答案

在主目录根目录下添加以下命令创建环境:
$ python3 -m venv venv此代码将在根目录中创建一个名为 venv 的文件夹。这基本上是虚拟环境文件夹。

然后添加以下命令来激活虚拟环境:
$ source venv/bin/activate

your_project_folder/
 |
 |-- your_main_app_folder/
 |         |
 |         |--Folder_with_controllers/
 |         |            settings.py
 |         |            urls.py
 |         |            ...
 |         | 
 |         |--App_folder/
 |         |--Other_app_folder/
 |
 |--venv/


如果代码运行良好,您的 bash 应该如下所示:(venv) <the_path_for_the_folder> your_project_folder %
激活环境后,您现在可以安装 django 和其他软件包。

Ps:确保您安装并激活不在your_main_app_folder中的虚拟环境文件夹.

关于django - 试图将 django 安装到我的虚拟环境中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60743351/

相关文章:

linux - 将列表插入字符串

linux - 这是在 ansible 的 conf 文件中进行配置更改的最佳方法

linux - insmod : error inserting 'usb338x.ko' : -1 Unknown symbol in module

python - 击中/static/位置时不提供 index.html

json - Ansible 2.0 解析 Json 并存储在另一个变量中

python - 将 GET 参数转换为 Django REST Framework 中 Request 对象上的 POST 数据

python - ./manage.py 权限被拒绝

django - 查看执行时间很长(一分钟以上)

python - django-crispy form - 隐藏字段标签

java - 错误 : package does not exist. 与问题代码相关吗?