简体   繁体   中英

I am not able to activate my virtual environment in linux

I am not able to activate the venv available in my project directory.

When I do the following it still doesn't activate the venv and I am not able to use python or pip installed in my venv.

/my_project$ source venv/bin/activate

(venv) /my_project$

It does show that the venv is activated but when I check python and pip, version and location it shows that both are from the root dir usr/bin/python & usr/bin/pip .

Venv Installation Process

/my_project$ python3.10 -m venv venv

It's working well in my new directory and I am also able to activate the venv but my existing venv in the project folder that I created yesterday is not starting. I am new to Linux and don't know much about it but I believe it has something to do with the Linux reboot as after the reboot this started happening. Any help would be appreciated. Thanks

OS: Ubuntu 20.04.4 LTS
system python: 3.8.10
python3.10: 3.10.5

perhaps try explicitly setting the python version when creating your venv:

ie

/my_project$ python -m venv venv python=python3.10

https://stackoverflow.com/a/61775880/14327910

and from ( https://python.land/virtual-environments/virtualenv ):

Blockquote Python 3.4 and above If you are running Python 3.4+, you can use the venv module baked into Python: $ python -m venv [directory] This command creates a venv in the specified directory and copies pip into it as well. If you're unsure what to call the directory: venv is a commonly seen option; it doesn't leave anyone guessing what it is. A little further in this article, we'll take a close look at the directory that was just created. But let's first look at how to activate this virtual environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM