Search code examples
pythonlinuxraspberry-pivirtualenvvirtualenvwrapper

Python virtual env error on Raspberry Pi after reboot


I am running Python 2.7 on a Raspberry Pi 3 with virtualenv, virtualenvwrapper installed. It's been fine for a few months, but when I booted the Pi this morning and ran "source .profile" it threw this error:

ValueError: bad marshal data (string ref out of range)

virtualenvwrapper.sh: There was a problem running the initialization hooks.

The Pi was not even connected to the internet when I first booted it this morning so I can't imagine anything has silently updated. I have since connected it to the internet and power cycled it but the error persists. From reading similar Q&As I assume my PATH is not set properly but I'm having trouble debugging it.

If it helps, this is how I installed it originally:

$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/.cache/pip

# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

$ echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.profile
$ echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.profile
$ echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile

Thanks for your time! :)


Solution

  • For the error, the line before:

    ValueError: bad marshal data (string ref out of range)

    was the line:

    import email.quoprimime

    So I ran:

    sudo rm /usr/lib/python2.7/email/quoprimime.pyc
    sudo /usr/bin/python -c "import email.quoprimime"
    

    And it is all fixed now.

    Thanks to user1767754 for pointing me in the right direction.