添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
笑点低的西红柿  ·  Sharing packages ...·  2 小时前    · 
善良的莴苣  ·  Solved: Query/issue ...·  2 小时前    · 
豪气的冲锋衣  ·  ModuleNotFoundError: ...·  2 小时前    · 
有腹肌的鸡蛋  ·  Upgrade of ...·  17 小时前    · 
发怒的芒果  ·  Can not build pytorch ...·  昨天    · 
踢足球的茄子  ·  ERROR ...·  5 月前    · 
严肃的石榴  ·  Webex应用程序支持策略·  5 月前    · 

My home server runs Ubuntu. Last night I upgraded it to the latest long term release, 22.04. This comes with Python 3.10.6 but as near as I can tell, no venv support. For example, trying to set up my usuall default venv:

[/home/cameron]borg*> /usr/bin/python3 -m venv ~/var/venv/3.10.6
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 install python3.10-venv
You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.
Failing command: ['/home/cameron/var/venv/3.10.6/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

but there doesn’t seem to be a python3.10-venv:

root@borg:/#     apt install python3.10-venv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python3.10-venv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python3.10-venv' has no installation candidate

Is there something basic I’m missing?

That seems very odd. Maybe it’s the suggested command that’s wrong. Try:

apt install python3-venv

I’m just guessing here though (since that’s the package name on Debian).

Very odd for sure, I tend to suspect something is wrong with your
package repository or sources list (like maybe you only included
main and not universe?). I have many Ubuntu 22.04 LTS servers with
the python3.10-venv package installed directly from Ubuntu’s package
mirrors.

Very odd for sure, I tend to suspect something is wrong with your
package repository or sources list (like maybe you only included
main and not universe?).

Hmm. This was an upgrade from an install maybe a year old? I had to use
the repos at the old-releases mirror to make it work.

But an apt-get check produced no complaints.

The upgrade added a line for jammy universe and commented it out!

 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
 ## team. Also, please note that software in universe WILL NOT receive any
 ## review or updates from the Ubuntu security team.
 deb https://mirror.aarnet.edu.au/ubuntu jammy universe # disabled on upgrade to jammy

I’ve uncommented it and done an apt-get update.

I have many Ubuntu 22.04 LTS servers with
the python3.10-venv package installed directly from Ubuntu’s package
mirrors.

Good to hear. It worked for me with the previous install (hirsute,
Python 3.9).

Now I get slightly better response. Examples:

 root@borg:/# apt-get install python3.10-venv
 Reading package lists... Done
 Building dependency tree... Done
 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.10-venv : Depends: python3.10 (= 3.10.4-3) but 
 3.10.6-1~22.04.2ubuntu1 is to be installed
 E: Unable to correct problems, you have held broken packages.

Chris’ suggested command:

 root@borg:/# apt-get install python3-venv
 Reading package lists... Done
 Building dependency tree... Done
 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-venv : Depends: python3.10-venv (>= 3.10.4-1~) but it is not 
 going to be installed
                 Depends: python3 (= 3.10.4-0ubuntu2) but 3.10.6-1~22.04 
 is to be installed
 E: Unable to correct problems, you have held broken packages.

My apt-fu is weak. dpkg says this:

 root@borg:/# dpkg -l|grep python3|grep venv
 rc  python3.9-venv                        3.9.5-3ubuntu0~21.04.1                  amd64        Interactive high-level object-oriented language (pyvenv binary, version 3.9)

Doubtless this stems from the previous state of this machine, but I
don’t know how to diagnose and/or repair at this point.

Suggestions?

Small rant:

  • my server has an SD card for the boot drive; very compact and cute but
    VERY SLOW
  • I’m not very enchanted by Ubuntu’s old release policy - I get that
    releases have end of life but the mirrors seem to evaporate, and with
    no mirror you can’t upgrade! I’ve very tired of doing fresh
    installs because of the downtime, rubbish install instructions and
    loss of config.
    I was saved only by the old-releases site, which I found just by
    chance after months of deferring this because the repos were all
    broken/gone.
  • I’m verging on using OpenBSD for this machine because of this pain; as
    an install and upgrade experience, OpenBSD kicks butt - every release I
    think they can’t make the install more streamlined and friendly, and
    every release just get s better. Not having systemd would be an added
    bonus. No docker though (which I’m starting to use to insulate me from
    some stale apps by running shiny new ones in a container).

    Cheers,
    Cameron Simpson [email protected]

    I’m verging on using OpenBSD for this machine because of this pain; as
    an install and upgrade experienc

    I moved away from openbsd to fedora because of issue with out of date software.
    Using fedora server i find is very reliable for my file server, mac rime machine server, and imap server.

    I do run a lot of fedora hosts, router, file server, music server and work ststion with VMs.

    I do update every 6 months to keep current.

    My work laptop was 22.04 (i now have 22.10). I had to install two packages.
    python3-pip and python3-venv to get venv to work i recall.

    Fyi in debian world i found i needed to install apt-file command to be able to search for packages by content.
    apt install apt-file i think then apt-file update and finally apt-file search …

    Well python3-pip installed. python3-venv says:

     The following packages have unmet dependencies:
      python3.10-venv : Depends: python3.10 (= 3.10.4-3) but 3.10.6-1~22.04.2ubuntu1 is to be installed
     E: Unable to correct problems, you have held broken packages.
    

    So: python3.10-venv requires Python 3.10.4 ? And I’ve got 3.10.6
    installed? An apt-get update doesn’t change the situation.

    apt-mark showhold recites nothing.

    Cheers,
    Cameron Simpson [email protected]

    Python package installer (pip wheel)
  • python3-setuptools-whl
    Python Distutils Enhancements (wheel package)
  • python3.10 (= 3.10.4-3) [not amd64, i386]
    Interactive high-level object-oriented language (version 3.10)
    python3.10 (= 3.10.6-1~22.04.2ubuntu1) [amd64, i386]
  • python3.10-distutils
    virtual package provided by python3-distutils
  • Note the different versions for the python dependency depending on the processor architecture. It looks like apt is trying to install python3-venv for a non-amd64/i368 architecture, hence the Depends: python3.10 (= 3.10.4-3). But python 3.10.6-1~22.04.2ubuntu1, which you have, is only available on amd64 and i368.

    Do you have some kind of multiarch enabled?

    Well:

    [/home/cameron]borg*> dpkg -l|grep 3.10
    ii  fuse3                                 3.10.5-1build1                          amd64        Filesystem in Userspace (3.x version)
    ii  libblas3:amd64                        3.10.0-2ubuntu1                         amd64        Basic Linear Algebra Reference implementations, shared library
    ii  libcdparanoia0:amd64                  3.10.2+debian-14build2                  amd64        audio extraction tool for sampling CDs (library)
    ii  libfuse3-3:amd64                      3.10.5-1build1                          amd64        Filesystem in Userspace (library) (3.x version)
    ii  libgusb2:amd64                        0.3.10-1                                amd64        GLib wrapper around libusb1
    ii  liblapack3:amd64                      3.10.0-2ubuntu1                         amd64        Library of linear algebra routines 3 - shared version
    ii  libmp3lame0:amd64                     3.100-3build2                           amd64        MP3 encoding library
    ii  libpython3-dev:amd64                  3.10.6-1~22.04                          amd64        header files and a static library for Python (default)
    ii  libpython3-stdlib:amd64               3.10.6-1~22.04                          amd64        interactive high-level object-oriented language (default python3 version)
    ii  libpython3.10:amd64                   3.10.6-1~22.04.2ubuntu1                 amd64        Shared Python runtime library (version 3.10)
    ii  libpython3.10-dev:amd64               3.10.6-1~22.04.2ubuntu1                 amd64        Header files and a static library for Python (v3.10)
    ii  libpython3.10-minimal:amd64           3.10.6-1~22.04.2ubuntu1                 amd64        Minimal subset of the Python language (version 3.10)
    ii  libpython3.10-stdlib:amd64            3.10.6-1~22.04.2ubuntu1                 amd64        Interactive high-level object-oriented language (standard library, version 3.10)
    ii  python3                               3.10.6-1~22.04                          amd64        interactive high-level object-oriented language (default python3 version)
    ii  python3-all                           3.10.6-1~22.04                          amd64        package depending on all supported Python 3 runtime versions
    ii  python3-dev                           3.10.6-1~22.04                          amd64        header files and a static library for Python (default)
    ii  python3-distutils                     3.10.6-1~22.04                          all          distutils package for Python 3.x
    ii  python3-gdbm:amd64                    3.10.6-1~22.04                          amd64        GNU dbm database support for Python 3.x
    ii  python3-lib2to3                       3.10.6-1~22.04                          all          Interactive high-level object-oriented language (lib2to3)
    ii  python3-minimal                       3.10.6-1~22.04                          amd64        minimal subset of the Python language (default python3 version)
    ii  python3-tk:amd64                      3.10.6-1~22.04                          amd64        Tkinter - Writing Tk applications with Python 3.x
    ii  python3.10                            3.10.6-1~22.04.2ubuntu1                 amd64        Interactive high-level object-oriented language (version 3.10)
    ii  python3.10-dev                        3.10.6-1~22.04.2ubuntu1                 amd64        Header files and a static library for Python (v3.10)
    ii  python3.10-doc                        3.10.6-1~22.04.2ubuntu1                 all          Documentation for the high-level object-oriented language Python (v3.10)
    ii  python3.10-minimal                    3.10.6-1~22.04.2ubuntu1                 amd64        Minimal subset of the Python language (version 3.10)
    

    A full dpkg -l shows only amd64 and all in the Architecture column. I don’t believe I’ve got a multiarch install.

    Is there a clean way to scrub everything apt knows and to refetch from the stuff in sources.list?

    Cameron Simpson:

    Is there a clean way to scrub everything apt knows and to refetch from the stuff in sources.list?

    A clean way? No. You could try deleting the contents of /var/lib/apt/lists, which contains information apt has received from the repositories listed in sources.list. There is also /var/lib/apt/extended_states, which contains information about installed packages. Messing with either of these may or may not mess things up further.

    You can try apt -oDebug::pkgAcquire::Worker=1 install python3-venv. It’s extremely verbose and not very readable, but it will tell you, among other things, what architecture it is trying to install for. grep the output for “APT::Architecture=”.

    Well I’ve learnt little, alas. Your debug incantation didn’t actually produce anything more in the output. Maybe I’ve broken my apt stuff here.

    I’ve built 3.11.3 from source using the fine instructions here: