1

I have installed virtual environment using pyvenv-3.4 it didn't install pip and I am unable to install any modules into virtual environment

(py34devel) x@x-Latitude-E6400:~/venv/py34devel$ ls bin
activate  activate.csh  activate.fish  python  python3  python3.4

If I use pip it falls back on the default pip which is outside the virtual environment and tells that requirement already satisfied

(py34devel) x@x-Latitude-E6400:~/venv/py34devel$ pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local        
/lib/python2.7/dist-packages
Cleaning up...

I have installed Python3.4 prior to this using make altinstall and then I am trying to install requests.

Then I tried to download and run get-pip.py but it gave below error

 (py34devel) x@x-Latitude-E6400:~/venv/py34devel$ python get-pip.py
    Traceback (most recent call last):
    File "get-pip.py", line 20479, in <module>
    main()
    File "get-pip.py", line 20471, in main
      bootstrap(tmpdir=tmpdir)
    File "get-pip.py", line 20411, in bootstrap
      import pip
      zipimport.ZipImportError: can't decompress data; zlib not available

So I reconfigured Python3.4 with --with-zlib and installed it again but I get the same error

I tried to create virtual environment using virtualenv -p python3.4 but it again give zlib error

x@x-Latitude-E6400:~/venv$ virtualenv -p python3.4 phere
Running virtualenv with interpreter /usr/local/bin/python3.4
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 17, in <module>
    import zlib
ImportError: No module named 'zlib'

Could anyone please help to resolve this issue.

I need to install a virtual environment which has python3.4 and pip so I may install modules, the documentation says that pip is install by default but that is not the case here

Unless the --without-pip option is given, ensurepip will be invoked to bootstrap pip   
into the virtual environment.

I am didn't give --without-pip option but still pip isn't installed in the virtual environment

Please donot ask me to use python brew as I want to get this resolved either using pyvenv-3.4 or virtualenv

I also tried to install virtualenv using python2.7 and then installed python3.4 suing the --prefix=path_to_virtual_environment which did install python3.4 and the virtual environment had requests installed but python3.4 wouldn't import requests. It would give error that no module named requests exists.

anukalp
  • 2,780
  • 5
  • 15
  • 24
  • Are you trying to use `virtualenv` or `pyvenv`? Despite their similar names, they are different things: `virtualenv` is a third-party Python package for creating virtual environments that is quite popular; `pyvenv` is a new feature of Python 3.3 that creates virtual environments, *inspired by `virtualenv`, but not identical*. – icktoofay May 12 '14 at 05:53
  • I am using pyvenv-3.4, but I tired virtualenv as described in last paragraph above. Currently I am following the advice of eclaird by install the missing headers. Thanks for the reply! – anukalp May 12 '14 at 07:32

1 Answers1

3

You mention --with-zlib, but did you install the development headers from zlib-devel (or zlib-dev depending on your distro) before that? Install the headers and run the build again. Also, I recommend you install readline-devel and openssl-devel too.

tuomur
  • 6,888
  • 34
  • 37
  • Thanks a lot for replying, No I didn't install the headers, I am using Xubuntu-13.10 which zlib headers should I install, when I run apt-get I get a very long list of libs over 300 MB Do I need all these sudo aptitude install zlib1g-dev libreadline6-dev libdb4.8-dev libncurses5-dev? – anukalp May 12 '14 at 06:17
  • Is this exactly what I must be doing http://stackoverflow.com/questions/4047212/installing-python-2-7-on-ubuntu-10-4 – anukalp May 12 '14 at 06:20
  • Packages depend on other packages, which in turn depend on others... Yes, you need the whole chain of packages apt-get gives you. If you don't have any development packages installed yet it may be a long list. – tuomur May 12 '14 at 06:31
  • Thanks, I am installing everything apt-gives me, along with --with-zlib option which options do I need to give for readline and openssl while compiling again? – anukalp May 12 '14 at 07:04
  • As long as you have the devel packages installed, Python's `configure` should include them automatically. – tuomur May 12 '14 at 09:51