Display of “Canopy” on command line

2020-06-20 07:57发布

I have a basic terminal question. I just installed enthought's Canopy for Python on Snow Leopard, and (Canopy 64bit) continually shows up when I'm working on the command line.

EX: (Canopy 64bit) Macbook~[username]$

I've tried editing my bashrc file, to no avail.

bashrc currently has this:

# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
   return
fi

PS1="Macbook~\u\$"
# Make bash check its window size after a process completes
shopt -s checkwinsize

--

Is there any way to stop "(Canopy 64bit)" from displaying?

6条回答
仙女界的扛把子
2楼-- · 2020-06-20 08:21

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

查看更多
在下西门庆
3楼-- · 2020-06-20 08:25

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

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

查看更多
ゆ 、 Hurt°
4楼-- · 2020-06-20 08:26

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

查看更多
【Aperson】
5楼-- · 2020-06-20 08:27

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.

查看更多
啃猪蹄的小仙女
6楼-- · 2020-06-20 08:32

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.

查看更多
Ridiculous、
7楼-- · 2020-06-20 08:44

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.

查看更多
登录 后发表回答