64

After installing Python 2.7 on Windows XP, then manually setting the %PATH% to python.exe (why won't the python installer do this?), then installing setuptools 0.6c11 (why doesn't the python installer do this?), then manually setting the %PATH% to easy_install.exe (why doesn't the installer do this?), I finally tried to install a python package with easy_install, but easy_install failed when it couldn't install the pywin32 package, which is a dependency. How can I make easy_install work properly on Windows XP? The failure follows:

C:\>easy_install winpexpect
Searching for winpexpect
Best match: winpexpect 1.4
Processing winpexpect-1.4-py2.7.egg
winpexpect 1.4 is already the active version in easy-install.pth

Using c:\python27\lib\site-packages\winpexpect-1.4-py2.7.egg
Processing dependencies for winpexpect
Searching for pywin32>=214
Reading http://pypi.python.org/simple/pywin32/
Reading http://sf.net/projects/pywin32
Reading http://sourceforge.net/project/showfiles.php?group_id=78018
No local packages or download links found for pywin32>=214
Best match: None
Traceback (most recent call last):
  File "C:\python27\scripts\easy_install-script.py", line 8, in 
    load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1712, in main
    with_ei_usage(lambda:
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1700, in with_ei_usage
    return f()
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1716, in 
    distclass=DistributionWithoutHelpCommands, **kw
  File "C:\python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 211, in run
    self.easy_install(spec, not self.no_deps)
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 446, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 481, in install_item
    self.process_distribution(spec, dists[0], deps, "Using")
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 519, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "C:\python27\lib\site-packages\pkg_resources.py", line 563, in resolve
    dist = best[req.key] = env.best_match(req, self, installer)
  File "C:\python27\lib\site-packages\pkg_resources.py", line 799, in best_match
    return self.obtain(req, installer) # try and download/install
  File "C:\python27\lib\site-packages\pkg_resources.py", line 811, in obtain
    return installer(requirement)
  File "C:\python27\lib\site-packages\setuptools\command\easy_install.py", line 434, in easy_install
    self.local_index
  File "C:\python27\lib\site-packages\setuptools\package_index.py", line 475, in fetch_distribution
    return dist.clone(location=self.download(dist.location, tmpdir))
AttributeError: 'NoneType' object has no attribute 'clone'
gturri
  • 13,807
  • 9
  • 40
  • 57
Nick
  • 651
  • 1
  • 5
  • 4
  • 9
    @Rafe: That doesn't help him at all. –  Oct 25 '10 at 15:50
  • @Sergio Tapia: Just a suggestion. – Rafe Kettler Oct 25 '10 at 16:00
  • To answer one question above, the Python installer won't modify your PATH variable because 1) it can't modify the PATH correctly on uninstall, and 2) you can have multiple Python versions on the same system, and this can cause unexpected behavior. See http://bugs.python.org/issue3561 – Brandon Oct 25 '10 at 16:26
  • As to why setuptools isn't part of the standard Python distribution, see http://faassen.n--tree.net/blog/view/weblog/2009/11/09/0 – Brandon Oct 25 '10 at 16:29
  • 6
    Brandon: thanks for your input. I know this is a somewhat tangential discussion, I have to say that when you have a hard decision to make ,such as whether to set the PATH or which package manager to preload with the distribution, the best thing to do is to give the user the OPTION to do what they probably want anyway. Example: "Add python to path? If you don't know what this means, select yes. [yes] [no]" ... "Install setuptools and set their path? If you don't know what this means, select yes. [yes] [no]". This is not a perfect solution, but it beats the hell out of sending newbies to google. – Nick Oct 25 '10 at 17:18
  • Nick, I don't disagree with you. I think it would be better to have that option added as well. My intent was just to let you know that it had been filed as a bug report, and the reason given for why it was closed. I'd love to change it but not strongly enough to maintain the Windows installer code for Python! :) – Brandon Oct 25 '10 at 20:14
  • Has anyone managed to install this on Windows XP without using cygwin? I'm using this guide http://waveydavey.wordpress.com/home/computing/installing-review-board-10-alpha-2-on-windows-for-perforce/#InstallingReviewBoardonWindowsforPerforce-ClientInstallation but I can't follow it very well. – A. Murray Dec 01 '11 at 16:20

5 Answers5

22

If you are using windows 7 64-bit version, then the solution is found here: http://pypi.python.org/pypi/setuptools

namely, you need to download a python script, run it, and then easy_install will work normally from commandline.

P.S. I agree with the original poster saying that this should work out of the box.

Gabriel
  • 1,078
  • 1
  • 8
  • 15
9

One problem is that easy_install is set up to download and install .egg files or source distributions (contained within .tgz, .tar, .tar.gz, .tar.bz2, or .zip files). It doesn't know how to deal with the PyWin32 extensions because they are put within a separate installer executable. You will need to download the appropriate PyWin32 installer file (for Python 2.7) and run it yourself. When you run easy_install again (provided you have it installed right, like in Sergio's instructions), you should see that your winpexpect package has been installed correctly.

Since it's Windows and open source we are talking about, it can often be a messy combination of install methods to get things working properly. However, easy_install is still better than hand-editing configuration files, for sure.

Community
  • 1
  • 1
Brandon
  • 3,684
  • 1
  • 18
  • 25
  • Thank you for your help. By manually installing the pywin32 exe installer, easy_install was able to install the winpexpect package without errors. However, when I import that module within python, it dies with "ImportError: No module named resource". Is this yet another step I need to go through to get my python environment working properly? Or is it just a bug in the winpexpect module? – Nick Oct 25 '10 at 17:41
  • 1
    OK: found the solution: in addition to manually installing pywin32, I had to uninstall the pexpect and winpexpect modules, then reinstall just the winpexpect module. At this point everything works. – Nick Oct 25 '10 at 17:50
  • 1
    Let's be fair... The messiness isn't because windows is closed-source, it's because more effort has been put into making sure that the install process works smoothly on linux and windows has been an afterthought. There's no reason whatsoever easy_install couldn't download a package and use MSBuild to compile it for the local system if required. – Basic Mar 04 '16 at 10:52
7

Copy the below script "ez_setup.py" from the below URL

https://bootstrap.pypa.io/ez_setup.py

And copy it into your Python location

C:\Python27>

Run the command

C:\Python27? python ez_setup.py

This will install the easy_install under Scripts directory

C:\Python27\Scripts

Run easy install from the Scripts directory >

C:\Python27\Scripts> easy_install

Magnilex
  • 11,584
  • 9
  • 62
  • 84
kadi99
  • 71
  • 1
  • 2
1

For one thing, it says you already have that module installed. If you need to upgrade it, you should do something like this:

easy_install -U packageName

Of course, easy_install doesn't work very well if the package has some C headers that need to be compiled and you don't have the right version of Visual Studio installed. You might try using pip or distribute instead of easy_install and see if they work better.

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
  • It never installed fully. It crashed every time on dependencies. It may have *partially* installed before, but that's it. Since this module is for Windows, I assume it is precompiled. – Nick Oct 25 '10 at 16:00
1

If you are using Anaconda's Python distribution,

you can install it through pip

pip install setuptools

and then execute it as a module

python -m easy_install

Danilo Gasques
  • 666
  • 6
  • 16