How to use virtualenv with python3.6 on ubuntu 16.04?

I am using Ubuntu 16.04, which comes with Python 2.7 and Python 3.5. I installed Python 3.6 and symlink python3 on python3.6 through alias python3=python3.6.

Then I installed virtualenvusing sudo -H pip3 install virtualenv. When I checked, virtualenv was installed in the folder "/usr/local/lib/python3.5/dist-packages", so when I try to create virtualenv using python3 -m venv./venv1it python3 -m venv./venv1I got errors:

Error Command: ['/home/wgetdj/WorkPlace/Programming/Python/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

What should I do?

+24
source share
3 answers

We usually use $ python3 -m venv myvenvto create a new virtualenv (here myvenvis the name of our virtualenv).

, python3.5, python3.6 , .

. Debian/Ubuntu :

 The virtual environment was not created successfully because ensure pip is not available.  On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.
      apt-get installpython3-venv  
 You may need to use sudo with that command.  After installing the python3-venv package, recreate your virtual environment. 

python3-venv:

$ sudo apt-get install python3-venv

.. Debian/Ubuntu, , , :

Error Command: ['/home/wgetdj/WorkPlace/Programming/Python/myvenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

, virtualenv.

$ sudo apt-get install python-virtualenv
$ virtualenv --python=python3.6 myvenv

. ,

E: python3-venv

:

sudo apt install python3.6-venv
+32

python3.6 python3.6-venv python3.6-venv ppa:deadsnakes/ppa ppa:jonathonf/python-3.6

apt-get update \
&& apt-get install -y software-properties-common curl \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install -y python3.6 python3.6-venv
+8

I think the problem may be due to the wrong language. I added the /etc/environmentfollowing lines to fix this:

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

You need to get the source file from your bash with this command:

source /etc/environment
+1
source

Source: https://habr.com/ru/post/1690814/


All Articles