Display of “Canopy” on command line

China☆狼群 提交于 2019-12-03 15:58:25

It's in .bash_profile. But you'll probably have to log out and back in for it to take effect, once you remove it.

There's an option when you install to make Canopy your default python environment. Unfortunately, there doesn't appear to be a way to change that in the application settings.

To elaborate on previous answers: Canopy is based on a 3-layers system, layer 0 contains the bare minimum for the Canopy GUI to work; layer 1 contains all of the "System" packages, which are distributed with Canopy and may be updated when new versions come out; finally, layer 2 is the "User" environment where users can install any package they like. In this way, if the user installs a package that breaks Canopy, one may always fall back to layer 1, or even layer 0 to do a system reset.

The three layers are managed using a popular library, virtualenv. In virtualenv, you can create isolated Python environments with their own set of libraries. For example, if you are developing several application, each requiring conflicting packages, you can develop them in separate "virtual environments". Using virtualenv, Canopy is able to do the same: you may have multiple "User" environment (although that feature is not exposed through the GUI yet).

One activates a virtual environment using its "activate" script, which Canopy does in the .bash_profile line

~/Library/Enthought/Canopy_64bit/User/bin/activate

as pointed out by DJon .

By default, virtualenv modifies your bash prompt so that you can remember which virtual environment you are in, that's why you see the "(Canopy 64bit)" prompt. To get rid of it, you can remove the line from .bash_profile, but this means that you will have to manually point your system to the right python executable and the right libraries.

punchagan solution simply deactivates the default virtualenvprompt, leaving the Canopy virtual environment itself intact:

VIRTUAL_ENV_DISABLE_PROMPT=true

Comment out the if clause at lines 56--70 in

~/Library/Enthought/Canopy_64bit/User/bin/activate

To get rid of the unwanted addition to your bash prompt, close Canopy and then open
~/Library/Enthought/Canopy_64bit/User/bin/activate in a text editor. Comment out lines as follows (these are not commented out in original):

#if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
#    _OLD_VIRTUAL_PS1="$PS1"
#    if [ "x(Canopy 64bit) " != x ] ; then
#   PS1="(Canopy 64bit) $PS1"
#    else
#    if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
#        # special case for Aspen magic directories
#        # see http://www.zetadev.com/software/aspen/
#        PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
#    else
#        PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
#    fi
#    fi
#    export PS1
#fi

Now close your bash session and restart it. The prompt will now be back to normal.

You don't need to completely comment out the those lines in ~/Library/Enthought/Canopy_64bit/User/bin/activate. I just commented out the line

      #PS1="(Canopz 64bit) $PS1"

and replaced it with

    PS1="$PS1"

so you just let Canopy do what it has to do but get rid of the anoying extra text in the prompt.

Best.

Editing the activate script works as Arkog answered, but if when I just commented out the line I got something like:

-bash: /Users//Library/Enthought/Canopy_64bit/User/bin/activate: line 60: syntax error near unexpected token else' -bash: /Users/<username>/Library/Enthought/Canopy_64bit/User/bin/activate: line 60: else'

So I found it better to just replace that line with:

$PS1 = $PS1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!