简体   繁体   中英

Installing python 32 bit on 64 bit Kubuntu

I would like to switch form Windows to Linux for python development. Since I want to use pyside I need a 32 Bit python under my 64 Bit Kubuntu.

Running 32 Bit python under 64 Bit Windows is peace of cake. Under Linux it seems to be a lot of harder which makes me a little bit tired.

I tried to follow this guide: 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.

So how to fix this?

sudo apt-get install python2.7:i386 It will install 32-bit python and its dependencies.

An alternative is https://github.com/yyuu/pyenv , which manages different versions of 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. 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.

Installing multiple pythons inside one system feels messier than simply virtualizing the development system you really want.

@Mine answer is the best. Just add a step that might be needed.

  1. Check if you have Python2 already installed to purge it

    whereis python2
  2. If a Python2.x version was found, purge it (mine was 2.7 )

     sudo apt purge -y python2.7-minimal
  3. After this, you may carry what @mine stated in his answer

    sudo apt-get install python2.7:i386
  4. Verify that your new installed version is 32 bit

    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.

Reinstall your machine with 32 bit Kubuntu? Most users do not require the 64 bit support and a 32 bit version will run just fine on your 64 bit hardware.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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