Score:1

Cannot create venv as dependencies are unmet

mx flag

I am running on VirtualBox Ubuntu 18.04.5 LTS. I am running Python 3.6.9.

When trying to create a virtual environment with sudo python3 -m venv env I get:

admin@admin-VirtualBox:~/Desktop/project$ sudo python3 -m venv .venv
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the 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.

Failing command: ['/home/admin/Desktop/project/.venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

admin@admin-VirtualBox:~/Desktop/project$ python3 --version
Python 3.6.9
admin@admin-VirtualBox:~/Desktop/project$ sudo apt-get install python3.6-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python3.6-venv : Depends: python3.6 (= 3.6.5-3) but 3.6.9-1~18.04ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.
admin@admin-VirtualBox:~/Desktop/project$ 

I researched and found that python3 has venv already preinstalled. I believe there are some broken dependencies.

I tried:

admin@admin-VirtualBox:~/Desktop/project$ sudo apt-cache policy python3.6-venv python3.6 python3
python3.6-venv:
  Installed: (none)
  Candidate: 3.6.5-3
  Version table:
     3.6.5-3 500
        500 http://at.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
python3.6:
  Installed: 3.6.9-1~18.04ubuntu1.1
  Candidate: 3.6.9-1~18.04ubuntu1.1
  Version table:
 *** 3.6.9-1~18.04ubuntu1.1 100
        100 /var/lib/dpkg/status
     3.6.5-3 500
        500 http://at.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
python3:
  Installed: 3.6.7-1~18.04
  Candidate: 3.6.7-1~18.04
  Version table:
 *** 3.6.7-1~18.04 100
        100 /var/lib/dpkg/status
     3.6.5-3 500
        500 http://at.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Any suggestions how to fix this? What is the problem?

I appreciate your replies!

user535733 avatar
cn flag
`Depends: python3.6 (= 3.6.5-3) but 3.6.9-1~18.04ubuntu1.1`. The current version for 18.04 should be `3.6.9-1~18.04ubuntu1.6`, which suggests that your sources are stale or otherwise mucked up. @user.dz's answer below is an appropriate fix for that kind of problem.
Score:2
ng flag
  1. Run software-properties-gtk

    1st tab: Enable main, universe, 2nd tab: Enable security, updates

  2. Update list when you exit or run

    sudo apt update

  3. Install virtual environment module (I expected it installed on vanilla image)

    sudo apt install python3.6-venv

  4. Create virtual env without using sudo

    python3 -m venv .venv

Btw, it is good to confirm which is the linked version python3 using

ls -l $(which python3)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.