简体   繁体   English

在 64 位 Kubuntu 上安装 python 32 位

[英]Installing python 32 bit on 64 bit Kubuntu

I would like to switch form Windows to Linux for python development.我想从 Windows 切换到 Linux 进行 python 开发。 Since I want to use pyside I need a 32 Bit python under my 64 Bit Kubuntu.因为我想使用 pyside,所以我的 64 位 Kubuntu 下需要一个 32 位 python。

Running 32 Bit python under 64 Bit Windows is peace of cake.在 64 位 Windows 下运行 32 位 python 是轻而易举的事。 Under Linux it seems to be a lot of harder which makes me a little bit tired.在 Linux 下,它似乎要困难得多,这让我有点累。

I tried to follow this guide: https://stackoverflow.com/a/5507373我尝试按照本指南进行操作: https : //stackoverflow.com/a/5507373

But I got stuck here但我被困在这里

user1@user1-desktop:~/src/virtualenv-1.5.2/virtualenvs$ ~/.localpython/bin/virtualenv py2.7 --python=/home/user1/.localpython/bin/python2.7
Traceback (most recent call last):
File "/home/user1/.localpython/bin/virtualenv", line 2, in <module>
import virtualenv
File "/home/user1/.local/lib/python2.7/site-packages/virtualenv.py", line 17, in <module>
import zlib
ImportError: No module named zlib

Doing sudo apt-get install zlib1g-dev and recompile python doesn't help.执行sudo apt-get install zlib1g-dev并重新编译 python 没有帮助。

So how to fix this?那么如何解决这个问题呢?

sudo apt-get install python2.7:i386 It will install 32-bit python and its dependencies. sudo apt-get install python2.7:i386它将安装 32 位 python 及其依赖项。

An alternative is https://github.com/yyuu/pyenv , which manages different versions of Python.另一种方法是https://github.com/yyuu/pyenv ,它管理不同版本的 Python。

PySide 仅在 64 位 Python 窗口上不起作用。在 Linux 上它可以正常工作......所以只需使用

sudo apt-get install python-pyside

Why not just use VirtualBox to virtualize a 32 bit Kubuntu whenever you want to develop in 32 bit Python.当您想在 32 位 Python 中进行开发时,为什么不直接使用VirtualBox来虚拟化 32 位 Kubuntu。 That way you have the best of both worlds: your 64 bit system for normal use and a 32 bit system that you can fire up whenever you need it for Python development.这样你就拥有了两全其美的优势:正常使用的 64 位系统和 Python 开发需要时可以启动的 32 位系统。

Installing multiple pythons inside one system feels messier than simply virtualizing the development system you really want.在一个系统中安装多个 python 感觉比简单地虚拟化你真正想要的开发系统更麻烦。

@Mine answer is the best. @我的答案是最好的。 Just add a step that might be needed.只需添加一个可能需要的步骤。

  1. Check if you have Python2 already installed to purge it检查您是否已经安装了 Python2 来清除它

    whereis python2
  2. If a Python2.x version was found, purge it (mine was 2.7 )如果找到Python2.x版本,将其清除(我的是2.7

     sudo apt purge -y python2.7-minimal
  3. After this, you may carry what @mine stated in his answer在此之后,您可以携带@mine 在他的回答中所说的内容

    sudo apt-get install python2.7:i386
  4. Verify that your new installed version is 32 bit验证您新安装的版本是 32 位

    python2.7 -c 'import struct;print( 8 * struct.calcsize("P"))'

If it is ok, you shall get 32 meaning it is a 32 bit version.如果没问题,你会得到32意味着它是一个 32 位版本。

Reinstall your machine with 32 bit Kubuntu?用 32 位 Kubuntu 重新安装你的机器? Most users do not require the 64 bit support and a 32 bit version will run just fine on your 64 bit hardware.大多数用户不需要 64 位支持,32 位版本可以在您的 64 位硬件上正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM