VSCode上的Pipenv:为什么(pipenv)没有显示在终端上? [英] Pipenv on VSCode: Why is (pipenv) not displayed on the terminal?

查看:88
本文介绍了VSCode上的Pipenv:为什么(pipenv)没有显示在终端上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VSCode Bash终端上设置pipenv虚拟环境,但未显示(pipenv),这非常令人困惑.

I'm setting up pipenv virtual environment on VSCode Bash terminal but it's not showing (pipenv), which makes it very confusing.

当我使用Pycharm并配置Pipenv环境时,它将在项目路径后自动显示(pipenv),因此很容易判断我是否在使用pipenv.

When I was using Pycharm and let it configure pipenv environment, it would automatically display (pipenv) after the project path so it was very easy to tell whether I was on pipenv or not.

移至VSCode之后,我创建了一个项目目录,并通过 $ pipenv shell 在其中启动了pipenv环境,该环境可以初始化pipenv,但(pipenv)则不然显示在外壳上,而是显示在终端的右下角,如下所示: https://imgur.com/a/h3Ji8ZO

After I moved to VSCode, I made a project directory and started a pipenv environment inside it by $ pipenv shell which initialized pipenv stuffs fine but (pipenv) is not displayed on the shell and instead shown on the right corner of the terminal like this: https://imgur.com/a/h3Ji8ZO

显示终端的方式似乎由 scripts/activate 文件管理,但似乎该问题在某种程度上与pipenv和VSCode有关,所以我不确定如何正确解决此问题.

How terminal is shown seems to be managed by scripts/activate file but it seems the problem is somewhat related to both pipenv and VSCode so I'm not sure how to address this problem properly.

以下是与我的设置有关的一些代码.

Here's some of the codes related to my settings.

Jill@Jill-PC MINGW64 /e/VSCodeProjects/likelion (master)
$ pip -V
pip 19.2.1 from c:\users\jill\.virtualenvs\likelion-wdstza1r\lib\site-packages\pip (python 3.6)

Jill@Jill-PC MINGW64 /e/VSCodeProjects/likelion (master)
$ python --version 
Python 3.6.4 :: Anaconda, Inc.

Jill@Jill-PC MINGW64 /e/VSCodeProjects/likelion (master)
$ pipenv --version
pipenv, version 2018.11.26

推荐答案

要回答我自己的问题,是因为我不太了解VSCode的工作原理.

To answer my own question, it was because I was rather unfamiliar with how VSCode works.

与Pycharm之类的IDE不同,VSCode不会记住"以前使用的Python解释器.这意味着打开VSCode或首次使用pipenv创建虚拟环境时看到的Bash不是虚拟环境的外壳.

Unlike IDEs like Pycharm, VSCode doesn't 'remember' the previously used Python interpreter. This means that the Bash you see when you open up VSCode or when you first created a virtual environment with pipenv is not the virtual environment's shell.

您必须首先从命令面板中选择Python解释器,然后通过单击垃圾桶按钮关闭当前的bash shell,然后再次打开该shell.然后,您将在Bash的提示符下看到(venv_name),表明您正在创建的虚拟环境中.

You'll have to first select your Python interpreter from the command palette and close the current bash shell by clicking trash can button and open up the shell again. Then you'll see (venv_name) on the Bash's prompt which indicates that you're on the virtual environment you created.

这篇关于VSCode上的Pipenv:为什么(pipenv)没有显示在终端上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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