How do I install Python packages on Windows?

I'm having a hard time setting up python packages. EasyInstall from SetupTools is supposed to help that, but they don't have an executable for Python 2.6.

For instance to install Mechanize, I'm just supposed to put the Mechanize folder in C:Python24Libsite-packages according to INSTALL.txt, but runnning the tests does not work. Can someone help shed some light on this? Thanks!


The accepted answer is outdated. So first, pip is preferred over easy_install , (Why use pip over easy_install?). Then follow these steps to install pip on Windows, it's quite easy.

  • Install setuptools :

    curl https://bootstrap.pypa.io/ez_setup.py | python
    
  • Install pip :

    curl https://bootstrap.pypa.io/get-pip.py | python
    
  • Optionally, you can add the path to your environment so that you can use pip anywhere. It's somewhere like C:Python33Scripts .


  • Newer versions of Python for Windows come with the pip package manager. (source)

    pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4

    Use that to install packages:

    cd C:PythonScripts
    pip.exe install <package-name>
    

    So in your case it'd be:

    pip.exe install mechanize
    

    This is a good tutorial on how to get easy_install on windows. The short answer: add C:Python26Scripts (or whatever python you have installed) to your PATH.

    链接地址: http://www.djcxy.com/p/26366.html

    上一篇: “没有名为django.core.management的模块”

    下一篇: 我如何在Windows上安装Python软件包?