I am using Ubuntu server 12.04. The default python version is 2.7. I have installed python 3.3 in /opt directory. When I tried to create a virtualenv to use python 3.3, I get the following error:

$ virtualenv -p /opt/python3.3/bin/python3 python3_env
Running virtualenv with interpreter `/opt/python3.3/bin/python3`
Traceback (most recent call last):
  File `usr/lib/python2.7/dist-packages/virtualenv.py`, line 17, in 
`import zlib`
 ImportError: No module named 'zlib'

How do I resolve this?


First of all, I would recommend using deadsnakes ppa How do I install Python 3.3?

What you need to understand is your virtualenv package should be compatible with python3. I.e.virtualenv should be installed with python3.3. This can be done with easy_install OR pip compatible with python3.3.


Also python3.3 comes with inbuilt virtualenv which can be used as

python3.3 -m venv VIRTUAL_ENV_NAME


These binaries may be in /opt. So you may require full path.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.