0

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?

Community
  • 1
  • 1
avb
  • 1,701
  • 5
  • 22
  • 37
  • There is nothing in the [pyside build docs for linux](http://pyside.readthedocs.org/en/latest/building/linux.html) that indicates that it is 32-bit only. The example is even for a 64-bit system, as shown by the `x86_64` string in the name of the wheel file. – Roland Smith Jun 07 '15 at 14:44

5 Answers5

5

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.

Mine
  • 4,123
  • 1
  • 25
  • 46
  • This works, now I have python 32bit thank you. But pip is no longer installed. If I try `sudo apt-get install python-pip` apt wants to remove python2.7:i386 and python2.7-minimal:i386 again. How to reinstall pip for python 32 bit? – avb Jun 05 '15 at 09:45
  • What is the exact version of Python? Pip is included by default since 2.7.9. – awesoon Jun 07 '15 at 10:35
  • 1
    [*Install pip*](https://pip.pypa.io/en/stable/installing.html#install-pip) To install pip, securely download [get-pip.py](https://bootstrap.pypa.io/get-pip.py). [2] Then run the following (which may require administrator access): `python get-pip.py` Make sure you run right version of python. Use full path to python for sure. – Alex Kroll Jun 07 '15 at 10:56
  • 1
    I've just done sudo apt-get install python2.7:i386 again and noticed that this requires the removal of a lot of packages inculding pyhton 2.7 64Bit. Losing all this not acceptable for me. How to avoid this? – avb Jun 07 '15 at 12:37
  • Install package via `dpkg` may be helps you `apt-get download python2.7:i386; dpkg -i --force-not-root --root=$HOME package.deb` Where `package.deb` is a python package downloaded with `apt-get`. `dpkg` installs python into your home directory without covering system's python. Other way build from sources. I don't know what about dependencies, it's may has manual resolving. Chroot. – Alex Kroll Jun 07 '15 at 14:32
  • And check this link from Askubuntu: [How can I install a 32bit python on 64 bit Ubuntu](http://askubuntu.com/questions/29253/how-can-i-install-a-32bit-python-on-64-bit-ubuntu). – Alex Kroll Jun 07 '15 at 14:48
  • @avb An alternative: https://github.com/yyuu/pyenv, which looks better than virtualbox – Mine Jun 16 '15 at 05:45
0

PySide doesn't work on 64 bit Python only windows only.. on Linux it works as it should... so simply use

sudo apt-get install python-pyside
0

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.

clay
  • 1,757
  • 2
  • 20
  • 23
  • To speedup virtualbox creation you could use [vagrant](https://www.vagrantup.com/) which uses VirtualBox to run virtual environments, but drsticially simplifies the process of creation and accessing python within the VM. – mrh1997 Jun 24 '18 at 19:31
0

@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.

wbadry
  • 797
  • 16
  • 27
-2

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.

Tim Stoop
  • 346
  • 1
  • 12