Install python3-venv module on linux mint
Try running this command:
sudo apt-get install python3.4-venv
Then use this:
python3 -m venv test
the package name is python3.4-venv
and not python3-venv
.
I used pip3 to install virtualenv but I can't create venv and also I can't uninstall virtualenv
The fundamental problem here seems to be that you are mixing up two different packages.
Python 3 comes with a built-in virtual environment module venv
which is however not installed by default on Debian-based platforms. Like the error message says, apt-get install -y python3-venv
will install this package, which you can then use with python3 -m venv
.
virtualenv
is a separate third-party package which you invoke with the command virtualenv
. It's not a bad alternative, but if you are only just learning, I would suggest you simply ignore it for the time being.
Installing venv for python3 in WSL (Ubuntu)
Give this approach a shot:
Install the pip:
sudo apt-get install python-pip
Install the virtual environment:
sudo pip install virtualenv
Store your virtual environments somewhere:
mkdir ~/.storevirtualenvs
Now you should be able to create a new virtualenv
virtualenv -p python3 yourVenv
To activate:
source yourVenv/bin/activate
To exit your new virtualenv, just deactivate
How to install virtualenv without using sudo?
This solution is suitable in cases where no virtualenv
is available system wide and you can not become root to install virtualenv
. When I set up a debian for python development or deployment I always apt-get install python-virtualenv
. It is more convenient to have it around than to do the bootstrap pointed out below. But without root power it may be the the way to go:
There is a bootstrap mechanism that should get you going.
Read: http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python
In essence you would do this in your home directory in a unix environment:
Given your python is version 2.6
$ mkdir ~/bin
$ mkdir -p ~/lib/python2.6
$ mkdir -p ~/local/lib/python2.6/dist-packages
$ wget http://peak.telecommunity.com/dist/virtual-python.py
$ python virtual-python.py --no-site-packages
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ ~/bin/python ez_setup.py
$ ~/local/bin/easy_install virtualenv
$ ~/local/bin/virtualenv --no-site-packages thereyouare
There may be room for optimization. I don't like the local
path. Just bin
and lib
would be nice. But it does its job.
Related Topics
Opening a Python Thread in a New Console Window
Using Python 32 Bit in 64Bit Platform
Command 'X86_64-Linux-Gnu-Gcc' Failed with Exit Status 1
Simulate Mouse Clicks on Python
Pip Is Not Working for Python 3.10 on Ubuntu
Better Way to Script Usb Device Mount in Linux
Linux/Python: Encoding a Unicode String for Print
Pyserial Works Fine in Python Interpreter, But Not Standalone
Python: Interplay Between Lib/Site-Packages/Site.Py and Lib/Site.Py
Linux:Python:Clear Input Buffer Before Raw_Input()
Python's Equivalent for R's Dput() Function
Auto.Arima() Equivalent for Python
Converting Python Objects for Rpy2
Which Command to Use for Checking Whether Python Is 64Bit or 32Bit