4

I have installed virtualenv:

pip3 install --user virtualenv

Then I was trying to create an environment for my folder with the next command:

folder_name$ python -m venv ll_env

But instead of the desired result I've got an error:

__The virtual environment was not created successfully because ensurepip is not available.
On Debian/Ubuntu systems, you need to install python3-venv package using the following command.

apt-get install python3-venv

You may need to use sudo with that command.
After installing the python3-venv package, recreate your virtual environment.__

However despite thr error virtualenv folder named ll_env created.

I have no idea why I receive this error. I'm new to Linux. I tried to check if virtualenv exists on system with this command:

pip3 show virtualenv

And I got:

Name: virtualenv
Version: 16.0.0
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Ian Bicking
Author-email: ianb@colorstudy.com
License: MIT
Location: /home/just_maverick/.local/lib/python3.6/site-packages
Requires:
Zanna
  • 70,465
Alex
  • 457
  • And don't keep us in suspense! Have you or have you not followed the request of your friendly Python and tried to install the package python3-venv by running the command sudo apt-get install python3-venv? – AlexP May 27 '18 at 15:18
  • No, I ran that command:

    pip install --user virtualenv

    – Alex May 27 '18 at 15:21
  • have you tried virtualenv foldername yet...? – sugab May 27 '18 at 15:25
  • So the poor Python tried to obey your command, and it could not, and it asked you to help it by installing a piece of software on your computer. How can you be so stone-hearted and refuse the request of your Python? – AlexP May 27 '18 at 15:28
  • 1
    Do what the error message tells you to do and you won't see that error message anymore. – karel May 27 '18 at 15:41
  • I read that installing packages with sudo it's a bad practice, and therefore I did not follow to system's advices. – Alex May 27 '18 at 15:43
  • 1
    "I read that installing packages with sudo it's a bad practice": citation needed. – AlexP May 27 '18 at 16:16
  • @AlexP What is clearly false requires no citation. apt-get install python3-venv E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? – Elder Geek May 27 '18 at 17:30
  • @karel that looks like an answer to me.... – Elder Geek May 27 '18 at 17:31
  • @ElderGeek: I believe that the inquirer has indeed read something which mentioned that it's bad practice to install some things with sudo, maybe referring to Python modules. I believe that they are in confusion about what they have read, where it applies, and why. That's why I wanted to elicit a remembrance of said reading. – AlexP May 27 '18 at 17:51
  • @AlexP I understand the motivation, and didn't intend to indicate that the OP hadn't been misled, but IMHO obtaining the source may have a similar unintended consequence as naming a school shooter. Adding to the fame of a con artist isn't something I would encourage. – Elder Geek May 27 '18 at 17:56

1 Answers1

8

As pointed out by this comment by karel.

The answer to your question is actually in your question:

__The virtual environment was not created successfully because ensurepip is not available.
On Debian/Ubuntu systems, you need to install python3-venv package using the following command.

apt-get install python3-venv

You may need to use sudo with that command.

To clarify, simply issue the command sudo apt-get install python3-venv or sudo apt install python3-venv either of which will install the python3-venv package, provided of course that you've enabled the universe repository first.

After installing the python3-venv package, recreate your virtual environment.__

Good programmers will often provide hints or outright solutions to problems that are likely to occur. This is an example of the latter.

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • It was almost obvious to me that I needed to execute command with sudo. But as a beginner I tried to follow advice of one experienced? programmer and like grim death intended to avoid granting root access. It was not very smart, but I was misled with it. – Alex May 28 '18 at 08:14
  • @AlexStelmakh You've put your finger on the reason I'm obsessed with testing. Although I've done some programming over the years with several (many now obsolete) languages, I'm first and foremost a troubleshooter who has a firm belief that change is the only constant. I'm glad my answer was useful to you. Cheers! ;-) – Elder Geek May 28 '18 at 17:26
  • Thanks for the anwser. you need to remove a dash - from the sudo apt install python-3-venv should be sudo apt install python3-venv, then it works :) – minisaurus Dec 10 '22 at 13:55
  • @minisaurus Nice catch, feel free to help out by editing any errors such as the aforementioned that you find on the site. – Elder Geek Dec 11 '22 at 15:16