PolicyStat / terrarium

Package and ship relocatable python virtualenvs, like a boss.
https://terrarium.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
171 stars 14 forks source link

"ImportError: No module named setuptools" error when invoking terrarium on a requirements file with "pyramid" #37

Closed msabramo closed 11 years ago

msabramo commented 11 years ago
marca@marca-mac:~/python/virtualenvs$ cat testenv.requirements
SQLAlchemy==0.8.1
pyramid==1.4.2

marca@marca-mac:~/python/virtualenvs$ terrarium --target testenv install testenv.requirements
Building new environment
New python executable in /Users/marca/python/virtualenvs/testenv/bin/python
Installing distribute...........................................................................................................................................................................................................................done.
Installing pip................done.
Downloading/unpacking SQLAlchemy==0.8.1
  Using download cache from /Users/marca/.pip/download-cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2FS%2FSQLAlchemy%2FSQLAlchemy-0.8.1.tar.gz
  Running setup.py egg_info for package SQLAlchemy

    warning: no files found matching '*.jpg' under directory 'doc'
    no previously-included directories found matching 'doc/build/output'
Downloading/unpacking pyramid==1.4.2
  Using download cache from /Users/marca/.pip/download-cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpyramid%2Fpyramid-1.4.2.tar.gz
  Running setup.py egg_info for package pyramid

Downloading/unpacking distribute (from pyramid==1.4.2)
  Using download cache from /Users/marca/.pip/download-cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fd%2Fdistribute%2Fdistribute-0.7.3.zip
  Running setup.py egg_info for package distribute
...
  Running setup.py install for Chameleon
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named setuptools
    Complete output from command /Users/marca/python/virtualenvs/testenv/bin/python -c "import setuptools;__file__='/Users/marca/python/virtualenvs/testenv/build/Chameleon/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nk/8f8f6wjn7v3b9cb2gjqf6vph0000gp/T/pip-QUzklA-record/install-record.txt --single-version-externally-managed --install-headers /Users/marca/python/virtualenvs/testenv/include/site/python2.7:
    Traceback (most recent call last):

  File "<string>", line 1, in <module>

ImportError: No module named setuptools

----------------------------------------
Traceback (most recent call last):
  File "/var/folders/nk/8f8f6wjn7v3b9cb2gjqf6vph0000gp/T/terrarium_bootstrap-fk1iCx.py", line 2635, in <module>
    main()
  File "/var/folders/nk/8f8f6wjn7v3b9cb2gjqf6vph0000gp/T/terrarium_bootstrap-fk1iCx.py", line 983, in main
    after_install(options, home_dir)
  File "/var/folders/nk/8f8f6wjn7v3b9cb2gjqf6vph0000gp/T/terrarium_bootstrap-fk1iCx.py", line 1965, in after_install
    requirementSet = c.run(options, args)
  File "/Users/marca/python/virtualenvs/testenv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 271, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Users/marca/python/virtualenvs/testenv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1185, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Users/marca/python/virtualenvs/testenv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 592, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/Users/marca/python/virtualenvs/testenv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/util.py", line 662, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command /Users/marca/python/virtualenvs/testenv/bin/python -c "import setuptools;__file__='/Users/marca/python/virtualenvs/testenv/build/Chameleon/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nk/8f8f6wjn7v3b9cb2gjqf6vph0000gp/T/pip-QUzklA-record/install-record.txt --single-version-externally-managed --install-headers /Users/marca/python/virtualenvs/testenv/include/site/python2.7 failed with error code 1 in /Users/marca/python/virtualenvs/testenv/build/Chameleon
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/terrarium", line 9, in <module>
    load_entry_point('terrarium==1.0.0rc4', 'console_scripts', 'terrarium')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/terrarium/terrarium.py", line 809, in main
    r = terrarium.install()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/terrarium/terrarium.py", line 209, in install
    new_target
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 1057, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Library/Frameworks/...ontents/MacOS/Python /var/folders/nk/8f8f..._bootstrap-fk1iCx.py --prompt=(testenv) /Users/marca/python/virtualenvs/testenv failed with error code 1

The strange thing is that it seems to be coming from Chameleon but if I replace "pyramid" with "Chameleon", then it seems to work fine.

marca@marca-mac:~/python/virtualenvs$ cat testenv.requirements
SQLAlchemy==0.8.1
Chameleon>=1.2.3

marca@marca-mac:~/python/virtualenvs$ terrarium --target testenv install testenv.requirements
Building new environment
...
  Running setup.py install for Chameleon

  Running setup.py install for SQLAlchemy
...
Successfully installed Chameleon SQLAlchemy
...
Copying bootstrap script to new environment
Terrarium is finished

Here's my setup:

marca@marca-mac:~/python/virtualenvs$ python -V
Python 2.7.3
marca@marca-mac:~/python/virtualenvs$ pip freeze | egrep 'distribute|terrarium|setuptools|virtualenv|pip'
distribute==0.6.45
pip-accel==0.9.7
terrarium==1.0.0rc4
virtualenv==1.9.1
kylegibson commented 11 years ago

Hi Marc! Thanks for posting this issue.

We experienced this same problem late last week. We tracked the problem to the recent release of distribute 0.7.3 on July 5. One of our requirements, selenium, specified distribute as a requirement without pegging a version. To solve this problem, we pegged distribute to 0.6.49, the latest 0.6.X version.

Here's where the problem occurs in your log file. Once the new distribute is installed, the error occurs on the next installation:

Downloading/unpacking distribute (from pyramid==1.4.2)
  Using download cache from /Users/marca/.pip/download-cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fd%2Fdistribute%2Fdistribute-0.7.3.zip
  Running setup.py egg_info for package distribute

This may be an issue with pip. Try the following, see if you experience the same error:

virtualenv --distribute foobar
source foobar/bin/activate
pip install -U pyramid==1.4.2 

This is the result I get. Notice that after downloading pyramid it downloads distribute. I suspect that this is because one of pyramid's requirements is setuptools, unpegged.

Downloading/unpacking pyramid==1.4.2
  Downloading pyramid-1.4.2.tar.gz (2.4MB): 2.4MB downloaded
  Running setup.py egg_info for package pyramid

Downloading/unpacking distribute from https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a (from pyramid==1.4.2)
  Downloading distribute-0.7.3.zip (145kB): 145kB downloaded
  Running setup.py egg_info for package distribute

Downloading/unpacking Chameleon>=1.2.3 (from pyramid==1.4.2)
  Downloading Chameleon-2.11.tar.gz (157kB): 157kB downloaded
  Running setup.py egg_info for package Chameleon

Downloading/unpacking Mako>=0.3.6 (from pyramid==1.4.2)
  Downloading Mako-0.8.1.tar.gz (407kB): 407kB downloaded
  Running setup.py egg_info for package Mako

    warning: no files found matching '*.xml' under directory 'examples'
    warning: no files found matching '*.mako' under directory 'examples'
    warning: no files found matching 'ez_setup.py'
    no previously-included directories found matching 'doc/build/output'
Downloading/unpacking WebOb>=1.2b3 (from pyramid==1.4.2)
  Downloading WebOb-1.2.3.tar.gz (191kB): 191kB downloaded
  Running setup.py egg_info for package WebOb

    no previously-included directories found matching '*.pyc'
    no previously-included directories found matching '*.pyo'
Downloading/unpacking repoze.lru>=0.4 (from pyramid==1.4.2)
  Downloading repoze.lru-0.6.tar.gz
  Running setup.py egg_info for package repoze.lru

Downloading/unpacking zope.interface>=3.8.0 (from pyramid==1.4.2)
  Downloading zope.interface-4.0.5.zip (173kB): 173kB downloaded
  Running setup.py egg_info for package zope.interface

    warning: no previously-included files matching '*.dll' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
Downloading/unpacking zope.deprecation>=3.5.0 (from pyramid==1.4.2)
  Downloading zope.deprecation-4.0.2.tar.gz
  Running setup.py egg_info for package zope.deprecation

Downloading/unpacking venusian>=1.0a3 (from pyramid==1.4.2)
  Downloading venusian-1.0a8.tar.gz (42kB): 42kB downloaded
  Running setup.py egg_info for package venusian

Downloading/unpacking translationstring>=0.4 (from pyramid==1.4.2)
  Downloading translationstring-1.1.tar.gz
  Running setup.py egg_info for package translationstring

    no previously-included directories found matching 'docs/_build'
Downloading/unpacking PasteDeploy>=1.5.0 (from pyramid==1.4.2)
  Downloading PasteDeploy-1.5.0.tar.gz
  Running setup.py egg_info for package PasteDeploy

Downloading/unpacking setuptools>=0.7 (from distribute->pyramid==1.4.2)
  Downloading setuptools-0.9.5.tar.gz (764kB): 764kB downloaded
  Running setup.py egg_info for package setuptools

Downloading/unpacking MarkupSafe>=0.9.2 (from Mako>=0.3.6->pyramid==1.4.2)
  Downloading MarkupSafe-0.18.tar.gz
  Running setup.py egg_info for package MarkupSafe

Installing collected packages: pyramid, distribute, Chameleon, Mako, WebOb, repoze.lru, zope.interface, zope.deprecation, venusian, translationstring, PasteDeploy, setuptools, MarkupSafe
  Running setup.py install for pyramid

    Installing ptweens script to /home/kyle/foobar/bin
    Installing proutes script to /home/kyle/foobar/bin
    Installing pshell script to /home/kyle/foobar/bin
    Installing prequest script to /home/kyle/foobar/bin
    Installing pviews script to /home/kyle/foobar/bin
    Installing bfg2pyramid script to /home/kyle/foobar/bin
    Installing pcreate script to /home/kyle/foobar/bin
    Installing pserve script to /home/kyle/foobar/bin
  Found existing installation: distribute 0.6.34
    Uninstalling distribute:
      Successfully uninstalled distribute
  Running setup.py install for distribute

  Running setup.py install for Chameleon
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named setuptools
    Complete output from command /home/kyle/foobar/bin/python -c "import setuptools;__file__='/home/kyle/foobar/build/Chameleon/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-a99peK-record/install-record.txt --single-version-externally-managed --install-headers /home/kyle/foobar/include/site/python2.7:
    Traceback (most recent call last):

  File "<string>", line 1, in <module>

ImportError: No module named setuptools

----------------------------------------
Command /home/kyle/foobar/bin/python -c "import setuptools;__file__='/home/kyle/foobar/build/Chameleon/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-a99peK-record/install-record.txt --single-version-externally-managed --install-headers /home/kyle/foobar/include/site/python2.7 failed with error code 1 in /home/kyle/foobar/build/Chameleon
Storing complete log in /home/kyle/.pip/pip.log
msabramo commented 11 years ago

Thanks, Kyle!

Yep, I get the same result with pip, so yeah I guess this is a result of that version of distribute which became a stub that simply installs setuptools. Something about that appears to be messed up.

And pegging distribute==0.6.49 in the requirements file seems to make pip and terrarium happier.

Thanks!