如何在wine中安装python3?

Roh*_*kar 8 wine python3

我们如何在 wine 中为 32 位 ubuntu 安装 python3?

使用winetricks python2.7是可能的,但我的应用程序是用 python3 编写的

我没有 Windows 来测试我的应用程序,所以我要走这条艰难的路

小智 5

Python 3.7 现在可以在较新版本的 wine 中运行。 该用户使用 wine 4.14 安装 python 3.7.4,而我目前在 wine 5.0-rc3 中使用 Python 3.7.6。我能够运行pyinstaller交叉编译,并且可以毫无问题地在 wine 中测试生成的 exe 包和源代码。我正在测试的应用程序有一个基于 PyQt5 的 GUI。

我首先尝试使用嵌入式 python 的@Hibou57 方法,它不需要更新的 wine 版本。虽然这适用于最小的 python 安装,但后来我遇到了很多烦人的问题,需要进行一些修改。当我无法弄清楚如何numpy在 wine 中的嵌入式 python 中安装时,我放弃了这种方法。

要在 wine 中安装 Python 3.7.6:

  1. 添加官方 Wine 存储库apt获取最新的开发版本
  2. 安装 wine 的开发者版本sudo apt install winehq-devel
  3. 只需在 wine 中下载并运行 Python 3.7.6 exe 安装文件即可wine cmd /c python-3.7.6.exe

下面的脚本是我在 docker 容器内安装 python 3.7.6 的脚本,以便使用 Ubuntu 18.04 映像进行交叉编译。我还使用 64 位 wine 前缀。请注意,此脚本的某些部分处理特定于 docker 的问题。

#!/bin/bash

set -e

echo "---------------------------------"
echo "-------- setup wine prefix ------"
echo "---------------------------------"
# We need the developer version of wine.  We need at least version 4.14 (see link).
# This is the earliest version I've seen reported to work with python3 well
# Without this, we'd have to run the embedded install of python which is riddled
# with annoying issues.

# see: https://appdb.winehq.org/objectManager.php?sClass=version&iId=38187

echo "------ Installing required apt packages ------"
apt update
apt install -y wget gnupg software-properties-common apt-utils

echo "------ Add latest wine repo ------"
# Need at least wine 4.14 to install python 3.7
dpkg --add-architecture i386
wget -nc https://dl.winehq.org/wine-builds/winehq.key
apt-key add winehq.key
apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
apt update

# Add repo for faudio package.  Required for winedev
add-apt-repository -y ppa:cybermax-dexter/sdl2-backport

echo "-------- Install wine-dev ------"

apt install -y \
    winehq-devel \
    winetricks \
    xvfb        # This is for making a dummy X server disply 

echo "------ Download python ------"
wget https://www.python.org/ftp/python/3.7.6/python-3.7.6-amd64.exe
#wget https://www.python.org/ftp/python/3.7.6/python-3.7.6.exe

echo "------ Init wine prefix ------"
WINEPREFIX=~/.wine64 WINARCH=win64 winetricks \
    corefonts \
    win10

# Setup dummy screen
Xvfb :0 -screen 0 1024x768x16 &
jid=$!

echo "------ Install python ------"
DISPLAY=:0.0 WINEPREFIX=~/.wine64 wine cmd /c \
    python-3.7.6-amd64.exe \
    /quiet \
    PrependPath=1 \
    && echo "Python Installation complete!"
# Display=:0.0 redirects wine graphical output to the dummy display.  
# This is to avoid docker errors as the python installer requires a display, 
# even when quiet install is specified.
Run Code Online (Sandbox Code Playgroud)


3Do*_*ons 1

Microsoft 提供免费的 Windows VM 映像供下载。它们旨在用于在 Internet Explorer 中测试网站,但它们仍然是功能齐全的 Windows 副本,您可以在其中安装 Python 3 并在比 Wine 更可靠的 Windows 环境中测试您的应用程序


Hib*_*u57 1

我有一个类似的问题:我必须在 Ubuntu 上开发一个 Python3 应用程序,该应用程序将在 Windows 上交付。我想使用pyInstaller从 Wine 生成 Windows 可执行文件,因为不幸的是我无法访问 Windows 盒子。但我也未能在 Wine 上安装 Python3。

\n\n

然而,可能还有另一种选择:使用 \xe2\x80\x99s 所谓的 python 嵌入式 zip 存档。参见这里:3.8。嵌入式分发\xc2\xa0(docs.python.org)

\n\n

您可以从版本下载页面下载它,如本例(示例)\xc2\xa0:\xc2\xa0 Python 3.5.2\xc2\xa0(python.org)

\n\n

你有两个:

\n\n
    \n
  • Windows x86-64 可嵌入 zip 文件
  • \n
  • Windows x86 可嵌入 zip 文件
  • \n
\n\n

这意味着您必须询问客户他/她运行的是 32 位还是 64 位 Windows。

\n\n

\xe2\x80\x99s并不完美,因为如果 Python3 无法在 Wine 中运行,则无法测试应用程序 \xe2\x80\x99s Windows 版本。但至少,\xe2\x80\x99 是一种打包应该在 Windows 上运行的东西的方法,希望源代码在 Windows 上的行为与在 Ubuntu 上的行为相同。至少,你应该在Ubuntu端进行开发,使用Python虚拟环境。见28.3。venv \xe2\x80\x94 创建虚拟环境

\n