Finish Python installs Setuptools to resolve problems encountered with Matplotlib __python

Source: Internet
Author: User
Tags md5
preparatory work

1. Install Python
2. Install NumPy
3. Set the python environment variable, the system environment variable path after adding C:\Python27; C:\Python27\Scripts Installation Setuptools

Using ez_setup.py automatic installation, save the end code for this page as a "ez_setup.py" file, and double-click to complete the installation automatically. Execute the easy_install command, the following results indicate correct installation, if there is a problem, close the currently open CMD window, reopen and then enter the command.

C:\users\admin>easy_install
error:no URLs, filenames, or requirements specified (=--help)
troubleshoot problems with using Matplotlib

Problem:

>>> Import matplotlib
traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line $, in <mod
ule>
    Raise Importerror ("matplotlib requires Dateutil")
Importerror:matplotlib requires

Workaround, use the installed Setuptools, execute the easy_install command, install Python-dateutil and pyparsing:

C:\users\admin>easy_install python-dateutil
C:\users\admin>easy_install pyparsing
code for ez_setup.py:
#!python "" "Bootstrap Setuptools installation If you want to use Setuptools in your package ' s setup.py, just include this
    File in the same directory with it, and add this to the top of your setup.py:: From Ez_setup import Use_setuptools Use_setuptools () If you are want to require a specific version of Setuptools, set a download mirror, or use a alternate D

Ownload directory, you can do and supplying the appropriate options to ' use_setuptools () '.
This file can also is run as a script to install or upgrade setuptools. "" "Import sys default_version =" 0.6c11 "Default_url =" http://pypi.python.org/packages/%s/s/setuptools/"% Sys.versi On[:3] Md5_data = {' Setuptools-0.6b1-py2.3.egg ': ' 8822caf901250d848b996b7f25c6e6ca ', ' Setuptools-0.6b1-py2.4.egg ': ' B79A8A403E4502FBB85EE3F1941735CB ', ' Setuptools-0.6b2-py2.3.egg ': ' 5657759d8a6d8fc44070a9d07272d99b ', ' Setuptoo Ls-0.6b2-py2.4.egg ': ' 4996a8d169d2be661fa32a6e52e4f82a ', ' Setuptools-0.6b3-py2.3.egg ': ' BB31C0FC7399a63579975cad9f5a0618 ', ' Setuptools-0.6b3-py2.4.egg ': ' 38a8c6b3d6ecd22247f179f7da669fac ', ' setuptools-0.6b4-py 2.3.egg ': ' 62045a24ed4e1ebc77fe039aa4e6f7e5 ', ' Setuptools-0.6b4-py2.4.egg ': ' 4cb2a185d228dacffb2d17f103b3b1c4 ', ' s Etuptools-0.6c1-py2.3.egg ': ' b3f2b5539d65cb7f74ad79127f1a908c ', ' Setuptools-0.6c1-py2.4.egg ': ' B45adeda0667d2d2ffe14009364f2a4b ', ' Setuptools-0.6c10-py2.3.egg ': ' ce1e2ab5d3a0256456d9fc13800a7090 ', ' Setuptools -0.6c10-py2.4.egg ': ' 57d6d9d6e9b80772c59a53a8433a5dd4 ', ' Setuptools-0.6c10-py2.5.egg ': ' De46ac8b1c97c895572e5e8596aeb8c7 ', ' Setuptools-0.6c10-py2.6.egg ': ' 58ea40aef06da02ce641495523a0b7f5 ', ' Setuptools -0.6c11-py2.3.egg ': ' 2baeac6e13d414a9d28e7ba5b5a596de ', ' Setuptools-0.6c11-py2.4.egg ': ' Bd639f9b0eac4c42497034dec2ec0c2b ', ' Setuptools-0.6c11-py2.5.egg ': ' 64c94f3bf7a72a13ec83e0b24f2749b2 ', ' Setuptools -0.6c11-py2.6.egg ': ' bfa92100bd772d5a213eedd356d64086 ', ' Setuptools-0.6c2-py2.3.egg ': ' F0064bf6aa2b7d0f3ba0B43f20817c27 ', ' Setuptools-0.6c2-py2.4.egg ': ' 616192eec35f47e8ea16cd6a122b7277 ', ' setuptools-0.6c3-py2.3.egg ': ' F1 81fa125dfe85a259c9cd6f1d7b78fa ', ' Setuptools-0.6c3-py2.4.egg ': ' e0ed74682c998bfb73bf803a50e7b71e ', ' setuptools-0. 6c3-py2.5.egg ': ' abef16fdd61955514841c7c6bd98965e ', ' Setuptools-0.6c4-py2.3.egg ': ' b0b9131acab32022bfac7f44c5d7971f ', ' Setuptools-0.6c4-py2.4.egg ': ' 2a1f9656d4fbf3c97bf946c0a124e6e2 ', ' setuptools- 0.6c4-py2.5.egg ': ' 8F5A052E32CDB9C72BCF4B5526F28AFC ', ' Setuptools-0.6c5-py2.3.egg ': ' ee9fd80965da04f2f3e6b3576e9d8167 ', ' Setuptools-0.6c5-py2.4.egg ': ' Afe2adf1c01701ee841761f5bcd8aa64 ', ' setuptools- 0.6c5-py2.5.egg ': ' a8d3f61494ccaa8714dfed37bccd3d5d ', ' Setuptools-0.6c6-py2.3.egg ': ' 35686b78116a668847237b69d549ec20 ', ' Setuptools-0.6c6-py2.4.egg ': ' 3c56af57be3225019260a644430065ab ', ' setuptools- 0.6c6-py2.5.egg ': ' b2f8a7520709a5b34f80946de5f02f53 ', ' Setuptools-0.6c7-py2.3.egg ': ' 209fdf9adc3a615e5115b725658e13e2 ', 'Setuptools-0.6c7-py2.4.egg ': ' 5a8f954807d46a0fb67cf1f26c55a82e ', ' Setuptools-0.6c7-py2.5.egg ': ' 45d2ad28f9750e7434111fde831e8372 ', ' Setuptools-0.6c8-py2.3.egg ': ' 50759d29b349db8cfd807ba8303f1902 ', ' setuptools- 0.6c8-py2.4.egg ': ' Cba38d74f7d483c06e9daa6070cce6de ', ' Setuptools-0.6c8-py2.5.egg ': ' 1721747ee329dc150590a58b3e1ac95b ', ' Setuptools-0.6c9-py2.3.egg ': ' a83c4020414807b496e4cfbe08507c03 ', ' setuptools- 0.6c9-py2.4.egg ': ' 260a2be2e5388d66bdaee06abec6342a ', ' Setuptools-0.6c9-py2.5.egg ': ' Fe67c3e5a17b12c0e7c541b7ea43a8e6 ', ' Setuptools-0.6c9-py2.6.egg ': ' ca37b1ff16fa2ede6e19383e7b59245a ',} import sys, o  S Try:from hashlib import MD5 except Importerror:from MD5 import MD5 def _VALIDATE_MD5 (Egg_name, data): if Egg_name In md5_data:digest = MD5 (data). Hexdigest () if Digest!= Md5_data[egg_name]: print >>sy  S.stderr, ("MD5 validation of%s failed!
                (Possible download problem?) " % Egg_name
            ) Sys.exit (2) return Data def use_setuptools (Version=default_version, Download_base=def Ault_url, To_dir=os.curdir, download_delay=15): "" "Automatically find/download Setuptools and make it available O N Sys.path ' version ' should be a valid Setuptools version number this is available as a egg for download under T  His ' download_base ' URL (which should end with a '/').  The ' To_dir ' is the directory where setuptools'll be downloaded, if it's not already available. 
    If ' Download_delay ' is specified, it should being the number of seconds that would be paused before a initiating,  Should one is required. If an older version of the Setuptools is installed, this routine'll print a message to ' Sys.stderr ' and raise
    It in a attempt to abort the calling script. "" "was_imported = ' pkg_resources ' in Sys.modules or ' Setuptools ' in Sys.modules def do_download (): Egg = Download_setuptools (VersiOn, Download_base, To_dir, Download_delay) sys.path.insert (0, egg) import setuptools; Setuptools.bootstrap_install_from = Egg Try:import pkg_resources except Importerror:return Do_do Wnload () try:pkg_resources.require ("setuptools>=" +version); return except Pkg_resources. Versionconflict, E:if was_imported:print >>sys.stderr, ("The required version of Setuptools (>=%s) is isn't available, and\n "can" t be installed while this script is running.
            Please install\n "" A more recent version I, using ' easy_install-u setuptools '. " \ n/currently using%r)% (version, e.args[0]) sys.exit (2) except Pkg_resources. Distributionnotfound:pass del pkg_resources, sys.modules[' pkg_resources '] # reload OK return do_downl Oad () def download_setuptools (Version=default_version, Download_base=default_url, to_dir=os.curdir, delay =): "" "Download setuptools from a specified location and return its filename ' V  Ersion ' should be a valid Setuptools version number this is available as a egg for download under the ' Download_base ' URL (which should end with a '/').
    ' To_dir ' is the directory where the egg would be downloaded.
    ' Delay ' is the number of seconds to pause before a actual download.  "" "Import urllib2, Shutil egg_name =" Setuptools-%s-py%s.egg "% (version,sys.version[:3]) URL = download_base + Egg_name SaveTo = Os.path.join (to_dir, egg_name) src = DST = None if not os.path.exists (SaveTo): # Avoid R epeated Downloads try:from distutils import log if Delay:log.warn ("" "- -------------------------------------------------------------------------This script requires Setuptools version%s  To-run (even to display Help). I'll attempt to download it for you (from%s), but May need to enable firewall access for this script.

I'll start the download in%d seconds. (Note:if This machine does isn't have network access, please obtain the ' file%s ' and place ' it in this directory before
rerunning this script.) ---------------------------------------------------------------------------"" ", Version, Download_base , delay, URL); From time to import sleep; Sleep (delay) Log.warn ("Downloading%s", url) src = urllib2.urlopen (URL) # Read/write a
            ll in one blocks, so we don ' t create a corrupt file # if the download is interrupted. data = _validate_md5 (Egg_name, Src.read ()) DST = open (SaveTo, "WB"); Dst.write (data) finally:if src:src.close () if Dst:dst.close () return Os.path.realpa
        Th (SaveTo) def main (argv, version=default_version): "" Install or upgrade Setuptools and Easyinstall "" Try: Import Setuptools except Importerror:egg = None Try:egg = Download_setuptools (version, delay=0) Sys.path.insert (0,egg) from Setuptools.command.easy_install Import main return Main (list (argv)
    +[egg]) # We've done this here Finally:if egg and os.path.exists (egg): os.unlink (egg) Else:if setuptools.__version__ = = ' 0.0.1 ': Print >>sys.stderr, ("You have an OBS  Olete version of Setuptools installed.
            please\n "" Remove it from your system entirely before rerunning this script. " ) Sys.exit (2) req = "setuptools>=" +version import pkg_resources Try:pkg_resources.req Uire (req) except Pkg_resources.
            VersionConflict:try:from setuptools.command.easy_install Import main except Importerror: From Easy_install Import main main (list (argv) +[download_setuptools (delay=0)] Sys.exit (0) # Try to force an exit Else:if Argv:from Setuptools.command.easy_install Import main Main (argv) else:print "Setuptools version", version, "or greater has been
            Alled. "

print ' (Run "Ez_setup.py-u setuptools" to reinstall or upgrade.) ' def update_md5 (filenames): "" "Update our built-in MD5 registry" "" ASE = Os.path.basename (name) f = open (name, ' RB ') md5_data[base] = MD5 (F.read ()). Hexdigest () F.clos E () data = ["%r:%r,\n"% it in Md5_data.items ()] Data.sort () Repl = "". Join (data) Import INS Pect srcfile = Inspect.getsourcefile (sys.modules[__name__]) F = open (Srcfile, ' RB '); src = f.read (); F.close () match = Re.search ("\nmd5_data = {\ n ([^}]+)}", SRC) if not match:print >>sys.stderr, "Int
        Ernal error! " Sys.exit (2) src = Src[:match.start (1)] + RepL + src[match.end (1):] f = open (Srcfile, ' W ') f.write (SRC) f.close () if __name__== ' __main__ ': If Len (sys. argv) >2 and sys.argv[1]== '--md5update ': Update_md5 (sys.argv[2:]) Else:main (sys.argv[1:])
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.