0

when I run the work command to get into my cv virtual environment on my pi it displays

pi@raspberrypi:~ $ workon cv
bash: workon: command not found

however when I ssh into my pi from my MacBook and run

pi@raspberrypi:~ $ workon cv

it displays

(cv)pi@raspberrypi:~ $

I'm quite new to raspberry pi's and I did spill some water on it a few days ago but it seems to be working fine, thanks in advanced for the help

  • Apparently the virtual environment setup is not initialised properly. Did you reboot the Pi after installing the virtualenv / virtualenvwrapper modules (which I assume you installed). – Dirk Oct 21 '18 at 19:17
  • yes and I have tried rebooting it multiple times, however when I run commands in the virtual environment off my MacBook everything seems to work okay until I try to install numpy and it crashes (or just takes very long), both times I have tried to install numpy. which is why I tried to do it directly from my pi, which is then when it wouldn't accept the "workon" command @Dirk – emilbowry Oct 21 '18 at 19:25
  • update it has just after 10 mins installed numpy from my MacBook @Dirk – emilbowry Oct 21 '18 at 19:34
  • 1
    Where / how is the initialisation for the virtualenvwrapper done? Did you add it to any of the startup / login script? I have added it to ~./bashrc, which will make sure it's done with every login – Dirk Oct 21 '18 at 20:09
  • I did it in the ~/.profile I think @Dirk – emilbowry Oct 21 '18 at 20:23
1

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
1

one method of doing this is by running:

source ~/.profile
workon cv
  • The OP is logged in as user pi. On login the script ~/.profile is executed. What makes it a difference executing it once again? – Ingo Apr 3 at 16:51
  • 2
    I currently don't have the expertise to know the exact reason why, but when I am logged in as user pi, and run workon cv without running source ~/.profile the workon command is not found. It works fine if source ~/.profile is run beforehand. I will look into this and update accordingly. – Damon Apr 3 at 17:12
  • That would be an interesting and important information. Maybe the path is broken? Check before and after execution of ~/.profile with this commands: which workon and echo $PATH. – Ingo Apr 3 at 21:37

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.