Display of "Canopy" on command line
Asked Answered
A

6

5

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?

Abbie answered 11/4, 2013 at 6:52 Comment(0)
H
1

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.

Hoffert answered 11/4, 2013 at 13:50 Comment(1)
This not only removes the additional text in your PS1, but also changes your PATH, removing the canopy scripts directory from your PATH. So, you'll have to give the full path to any scripts installed by Canopy to run them.Floreated
B
7

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

Banner answered 12/4, 2013 at 8:3 Comment(2)
Does Canopy install virtualenv somewhere? Or is this some partially virtualenv-like behavior provided by Canopy? virtualenv --help doesn't seem to work within my install of Canopy.Ingleside
Canopy is using a backport of the venv package that is available in Python 3. More information at enthought.zendesk.com/entries/…Banner
H
1

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.

Hoffert answered 11/4, 2013 at 13:50 Comment(1)
This not only removes the additional text in your PS1, but also changes your PATH, removing the canopy scripts directory from your PATH. So, you'll have to give the full path to any scripts installed by Canopy to run them.Floreated
E
1

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

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

Esbjerg answered 11/4, 2013 at 21:33 Comment(1)
Or set the environment variable VIRTUAL_ENV_DISABLE_PROMPT=true in your .bashrc or .bash_profile.Floreated
R
1

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.

Rattlebox answered 16/4, 2013 at 18:38 Comment(0)
E
0

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.

Eau answered 23/5, 2013 at 17:5 Comment(0)
G
0

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

Gudrin answered 24/5, 2013 at 17:51 Comment(1)
Commenting out the lines is a syntax error because the if has no statement before the else. You could replace it with ':' character, (the bash NOP statement) or 'true'. You should remove the '$' from the beginning of your replacement so it doesn't cause another syntax error.Ingleside

© 2022 - 2024 — McMap. All rights reserved.