I've installed and run virtuarenvwrapper.sh to try to configure an alternate version of python on my system. This script has placed somewhere a series of commands that are now executed whenever I open gnome-terminal. Now, when I open a terminal I see:

bash: which: command not found...
bash: -m: command not found...
virtualenvwrapper.sh: There was a problem running the initialization hooks. 

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
set properly.
user@localhost ~]$

I want to remove these commands but I can't find out where they are. I've looked in:

  • ~/.bash_profile
  • ~/.bashrc
  • /etc/bashrc

The commands run on my user terminal as well as root's terminal. What other places can one put commands to run upon opening a terminal?

  • The bits about deactivating the environment and then removing in this A..do they help in your case? unix.stackexchange.com/questions/103719/… – slm Jun 9 '14 at 16:55
  • @slm, the virtual environment wasn't successfully created so when I run rmvirtualenv, I get similar errors to what I get when opening a terminal. – drs Jun 9 '14 at 17:04
  • I think I had a similar issue when writing up that A 8-). I had to spend much of an evening using grep and ripping out all the cruft. – slm Jun 9 '14 at 17:17

I have a little function I use whenever I'm trying to track something like this down:

    grep -H "$@" ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
        /etc/bash.bashrc /etc/profile /etc/environment /etc/profile.d/* \
        /etc/pam.d/* 2>/dev/null

If you add that to your ~/.bashrc you can use it to look for any string in your bash's initialization files.

Note, however, that the likeliest case here is that your ~/bashrc or whatever is sourcing another file and that is the problematic one. So, try looking for the word source or the . character:

grep -wE '\.|source' ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
        /etc/bash.bashrc /etc/profile /etc/environment /etc/pam.d/*\ 
         /etc/profile.d/* 2>/dev/null

The culprit was a symlink at /etc/profile.d/virtualenvwrapper.sh

The solution was to either remove that symlink or, better, uninstall the package:

yum remove python-virtualenvwrapper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.