Installation of the Windows System Python package (continuous update ...) )

Source: Internet
Author: User

This article is for Python beginners, please take a detour for Python veteran.

Recently try to install Python-related packages on WINDOWS10, MacOS, Ubuntu three systems, overall comparison, Ubuntu the simplest, Windows10 the most complex.

Recommendation: If possible, use the Linux system as much as possible, and the WINDOWS10 system should be careful to enter the pit.

The following records the installation issues for the Windows Platform section related modules:

1. It is important to distinguish whether Python is 32-bit or 64-bit. Note: Not Windows systems, but Python.

View by: Enter Python in cmd, fancy the part of the red circle, a system

2, Pywin32

If Python is going to use a library of Windows system APIs, the first thing to install is pywin32, the official download link:

https://sourceforge.net/projects/pywin32/files/pywin32/

1) Click on the link above to see many versions, click on the version number to install, will enter a list,

Note: Please select the corresponding file according to the Python version and the number of bits in Python, for example

Pywin32-221.win-amd64-py2.6.exe-python2.6.x version (py2.6), 64bit (WIN-AMD64)

Pywin32-221.win32-py3.7.exe-python3.7.x version (py3.7), 32bit (Win32)

This must be selected correctly, or later will prompt "DLL load faild:%1 is not a valid Win32 program", which are 32bit and 64bit mismatch problem.

2) After downloading, there will be two problems during installation, "Python module not Found", or "Python is not registered" error.

Issue 1: The Python module cannot be found, and manually adding the Python directory is not supported.

Workaround, add a Python directory to the system's path.

Issue 2: This is a registry that needs to be imported.

The general workaround is to execute the Python program below to resolve it (this is the way it originated online).

1 #2# Script to register Python2.0or later forUse with Win32all3 # and other extensions that require Python registry settings4 #5# Written by Joakim Loew forSecret Labs AB/Pythonware6 #7 # Source:8# http://www.pythonware.com/products/works/articles/regpy20.htm9 #Ten# Modified by Valentine Gogichashvili asDescribedinchhttp//Www.mail-archive.com/[email protected]/msg10512.html One  A Import SYS -  -  from_winreg Import * the  -# tweak asnecessary -Version = sys.version[:3] -InstallPath =Sys.prefix +  -Regpath ="software\\python\\pythoncore\\%s\\"%(version) +Installkey ="InstallPath" APythonkey ="PythonPath" atPythonpath ="%s;%s\\lib\\;%s\\dlls\\"% ( - InstallPath, InstallPath, InstallPath - ) -  -  - def registerpy (): in     Try: -Reg =Openkey (HKEY_CURRENT_USER, Regpath) toExcept EnvironmentError ase: +         Try: -Reg =CreateKey (HKEY_CURRENT_USER, Regpath) the SetValue (Reg, Installkey, REG_SZ, InstallPath) * SetValue (Reg, Pythonkey, REG_SZ, Pythonpath) $ Closekey (REG)Panax Notoginseng except: -Print"* * * Unable to register!" the             return +Print"---Python", version,"is now registered!" A         return the     if(QueryValue (Reg, installkey) = =InstallPath and +QueryValue (Reg, pythonkey) = =Pythonpath): - Closekey (REG) $Print"= = = Python", version,"is already registered!" $         return - Closekey (REG) -Print"* * * Unable to register!" thePrint"* * * You probably has another Python installation!" - Wuyi  the if__name__ = ="__main__": -Registerpy ()

We carefully analyze the code, in fact, Pywin32 to check the registry before executing the following two items:

Hkey_current_user\software\python\pythoncore\x.x (note: version, e.g. 2.7,3.6)\installpath

The value of this key must be the path of the Python installation in the system path,

Hkey_current_user\software\python\pythoncore\x.x (note: version, e.g. 2.7,3.6)\pythonpath

The value of this key must be the path of the Python installation path, Lib, and DLLs in the system path, creating the corresponding key and assigning a value without finding it.

So you can also manually modify the regedit yourself.

3) through the Python environment, import Win32API to verify that the installation is successful.

3, the installation of Numby

Numby is a library of many modules, such as pandas, SciPy, matplotlib, and so on, because Numby uses a portion of C-compiled content, directly through the PIP, Easy_install, etc. will be wrong.

The following two ways are recommended:

Mode 1: Install the EXE installation package directly in https://sourceforge.net/projects/numpy/files/NumPy/download.

No need to pay attention to Python version and bit number, direct installation, convenient and quick.

Note: The latest version only provides EXE's installation package

Method 2: Download the precompiled package in http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy, install it via PIP

Note the 1:python version and the number of digits, if not correct, will be an error when installing.

NUMPY?1.11.3+MKL?CP27?CP27M?WIN32.WHL-python2.7.x version (CP27), 32bit (Win32)

NUMPY?1.11.3+MKL?CP36?CP36M?WIN_AMD64.WHL-python3.6.x version (CP36), 64bit (WIN_AMD64)

NOTE 2: Upgrade the PIP version before you install it, or it may fail.

4, the installation of scipy

SCIPY installation and NumPy similar, there are two ways, refer to the NumPy

Way 1:https://sourceforge.net/projects/scipy/files/scipy/

Way 2:http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

5, the installation of Graphviz

Graphviz is an image software that is connected by Pygraphviz under Python.

1) Download and install Graphviz

http://www.graphviz.org/Download_windows.php

2) Download the Pygraphviz source package and unzip it, please use the Administrator privileges to open the decompression tool to extract

https://pypi.python.org/pypi/pygraphviz/

Install via Python setup.py install, the final error will be prompted.

3) Download the Pygraphviz precompiled package and execute it, Note the version and the number of digits

  http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygraphviz

After downloading the installation via Pip, you will be prompted for success.

3) Execute the following command

Pip install Pygraphviz--install-option= "--include-path=xxxx\graphviz2.38\include"--install-option= "-- Library-path=xxxx\graphviz2.38\lib\release\lib"

Use the full path instead of the red part above and the execution will prompt you to succeed.

This Pygranphviz complete installation successfully, via import Pygraphviz

    

Installation of the Windows System Python package (continuous update ...) )

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.