0

I have an RPi3B+ which I can connect to through either Putty or VNC, both work fine. I've installed virtualenv with pip install virtualenv virtualenvwrapper.

When I'm connected through Putty and I issue the command workon <envname> I can enter the virtual environment without issue, but when I do the same having opened up a terminal in VNC, I get bash: workon: command not found.

I've issued pip install virtualenv virtualenvwrapper on VNC, and it's definitely there, but still get command not found.

Also, python modules that I've imported while connected by VNC aren't available when connected by Putty.

Why the difference? Aren't they just two different ways to access the same machine?

  • sounds like you added the activation code in the wrong file. Which file did you add the code to? If it's in ~/.profile you should change that to ~/.bashrc. See comments on raspberrypi.stackexchange.com/questions/90173/… (as you can see it's not confirmed it's the issue, but I'm fairly sure) – Dirk Oct 26 '18 at 1:24
  • Yes, I did put it in ~/.profile now that you mention it. I added the lines export WORKON_HOME=$HOME/.virtualenvs \ export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 \ source /usr/local/bin/virtualenvwrapper.sh to the file. Do I need to put those into ~/.bashrc too? – Jim421616 Oct 26 '18 at 1:27
  • Ah, apparently I do. @Dirk if you change your comment to an answer, I'll accept it. – Jim421616 Oct 26 '18 at 1:32
0

This can happen when you put the activation code for virtualenvwrapper in the wrong bash startup script.

~/.profile is not run on a non-login shell (like the terminal started in the GUI). It is run if you log in using SSH. To have it activated in both situations you can move the code over to ~/.bashrc

NB: the code you have to move looks something like this. This is what's in my .bashrc, but it will be slightly different on your system

export WORKON_HOME=$HOME/dev/virtenv
export PROJECT_HOME=$HOME/dev
source /usr/local/bin/virtualenvwrapper.sh

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.