Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I changed my directory name and now my venv isn't working

Changed my dir name from a test/development directory name to a proper name for release. (changed to "project" for this question because the actual name is rather long)

Now when I activate my venv, I get the following:

(virtualEnv) PS ~\Desktop\dev\vbvarsel> pip --list
Fatal error in launcher: Unable to create process using '"~\Desktop\dev\project_0.0.1\virtualEnv\Scripts\python.exe"  "~\Desktop\dev\project\virtualEnv\Scripts\pip.exe" --list': The system cannot find the file specified.

I went into my pyvenv.cfg, and the activate scripts to modify the path to the venv’s python and pip exes (this is the correct one ~\Desktop\dev\project\virtualEnv), but it doesn’t seem to be registering this? This [~\Desktop\dev\project_0.0.1\virtualEnv\Scripts\python.exe] is causing the error, it is looking at the wrong directory, I don’t know where it is reading that from. It is not a system variable, if I search the files in this directory, it doesn’t yield any results. Have I just completely borked it and need to start from scratch with my virtual environment?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I am on Windows 11, using VSCode, if that should help.

>Solution :

You can’t easily move or rename virtualenvs once they’re created (nor can you use a virtualenv if the base interpreter you used to create it is gone, but that’s not the case here).

Your easiest bet is to simply recreate the virtualenv and trash the old one – and that should be fine! Virtualenvs shouldn’t be precious and special.

If you need the exact packages you had in there (e.g. you don’t have a requirements.txt or pyproject.toml for your requirements yet), place the virtualenv back where it was, activate it, run pip freeze > frozen-requirements.txt; you can then pip install -r frozen-requirements.txt in the new virtualenv.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading