[Python] How do I reset PYTHONPATH to "default" value in virtualenv?

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I was struggling with installing dependencies for an external library (the requirements were already fulfilled) when I read that I should check if the install path is in my PYTHONPATH. It wasn't, so I looked up how to add it.

    I came across this answer, and typed the code straight into the Terminal (not ~/.bashrc) before I finished reading.


    If you're using bash (on a Mac or GNU/Linux distro), add this to your ~/.bashrc

    export PYTHONPATH="${PYTHONPATH}:/my/other/path"
    ​

    The path was I entered was /usr/bin/python.

    Surprisingly this fixed all of my dependency problems.

    However, since my Django project is dependent on a virtualenv, this ruined everything. I can no longer find how or where to restore my PYTHONPATH to.

    I tried export PYTHONPATH="/home/[username]/.virtualenvs/[env]/bin/python" and also deleting the virtualenv with rmvirtualenv.

    My next plan is to delete the project and pull again.

    Continue reading...

Compartilhe esta Página