python從零安裝

一 python

1.安裝pythonphp

https://www.python.org/html

環境變量path添加 ;C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Scriptspython

2.安裝easy_installlinux

https://pypi.python.org/pypi/ez_setupc++

解壓後tar.gz進入目錄 python setup.py installexpress

3.安裝pipubuntu

https://pypi.python.org/pypi/pipwindows

解壓後tar.gz進入目錄 python setup.py installbash

4.whl安裝方法 pip install 「xxxwhl」app

二 windows

1.下載wxpython,經過exe安裝

http://wxpython.org/download.php

2.下載matplotlib,經過pip install 「xxxwhl」安裝  https://pypi.python.org/pypi/matplotlib/

http://matplotlib.org/users/installing.html

For standard Python installations you will also need to install compatible versions of setuptools, numpy, python-dateutil, pytz, pyparsing, and cycler in addition to matplotlib.

3.經過pip install pyinstaller安裝py2exe

http://pythonhosted.org/PyInstaller/#using-pyinstaller

4.進入py文件目錄,pyinstaller xxxpy -F 生成單一exe

 

三 ubuntu linux

 1.import tkFileDialog

>>> import tkFileDialog
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/lib-tk/tkFileDialog.py", line 43, in <module>
    from tkCommonDialog import Dialog
  File "/usr/lib/python2.7/lib-tk/tkCommonDialog.py", line 11, in <module>
    from Tkinter import *
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
    raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package

http://stackoverflow.com/questions/4783810/install-tkinter-for-python

apt-get install python-tk 不是pip install python-tk

 

2.import wx

http://wxpython.org/download.php

Linux Binaries
To get prebuilt binaries for Linux or other platforms, please search in your distro's package repository, or any 3rd party repositories that may be available to you. Ubuntu users can get information about the the wx APT repository here. If all else fails you can build wxPython yourself from the source code, see the next section.

http://wiki.wxpython.org/InstallingOnUbuntuOrDebian

(1)curl http://apt.wxwidgets.org/key.asc | sudo apt-key add -

(2)/etc/apt/sources.list

    # wxWidgets/wxPython repository at apt.wxwidgets.org
    deb http://apt.wxwidgets.org/ DIST-wx main
    deb-src http://apt.wxwidgets.org/ DIST-wx main

 (3)sudo apt-get update

(4)sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n

(5)import wx

 

3. from matplotlib.figure import Figure


http://matplotlib.org/users/installing.html

sudo apt-get install python-matplotlib


4. from bs4 import BeautifulSoup

 

https://pypi.python.org/pypi/beautifulsoup4

https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html

若是你用的是新版的Debain或ubuntu,那麼能夠經過系統的軟件包管理來安裝:

$ apt-get install Python-bs4

Beautiful Soup支持Python標準庫中的HTML解析器,還支持一些第三方的解析器,其中一個是 lxml .根據操做系統不一樣,能夠選擇下列方法來安裝lxml:

$ apt-get install Python-lxml

 

 

from docx  import Document

Reading http://pypi.python.org/simple/lxml/
https://pypi.python.org/simple/python-docx/

pip install python-docx 提示須要lxml,安裝lxml提示Unable to find vcvarsall.bat

http://zhidao.baidu.com/question/551990477.html

http://www.microsoft.com/express/Downloads/#2008-Visual-CPP去下載visual c++ 2008 express edition 

又提示:

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
cl: 命令行 warning D9025 :正在重寫「/W3」(用「/w」)
lxml.etree.c
src\lxml\includes\etree_defs.h(14) : fatal error C1083: 沒法打開包括文件:「libxml/xmlversion.h」: No such file or directory
Compile failed: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
xmlXPathInitproty2.c
c:\users\win7\appdata\local\temp\easy_install-4z6i_4\lxml-3.6.4\temp\xmlXPathInitproty2.c(1) : fatal error C1083: 沒法打開包括文件:「libxml/xpath.h」: No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: Setup script exited with error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

參考 http://zzq635.blog.163.com/blog/static/19526448620132845436686/ 去http://xmlsoft.org/sources/win32/ 下載相關文件

仍是不行,仍是直接安裝exe?

https://pypi.python.org/pypi/lxml/3.6.0 解決問題。

 

PIP3 報錯 升級pip

Fatal error in launcher: Unable to create process using '"'

 

C:\Users\win7>python3 -m pip install --upgrade pip

Collecting pip  Using cached pip-9.0.1-py2.py3-none-any.whlInstalling collected packages: pip  Found existing installation: pip 7.1.0    Can't uninstall 'pip'. No files were found to uninstall.Successfully installed pip-9.0.1You are using pip version 7.1.0, however version 9.0.1 is available.You should consider upgrading via the 'python -m pip install --upgrade pip' command.C:\Users\win7>pip3 install PillowCollecting Pillow  Downloading Pillow-4.1.1-cp36-cp36m-win_amd64.whl (1.5MB)    100% |████████████████████████████████| 1.5MB 441kB/sCollecting olefile (from Pillow)  Downloading olefile-0.44.zip (74kB)    100% |████████████████████████████████| 81kB 900kB/sInstalling collected packages: olefile, Pillow  Running setup.py install for olefile ... doneSuccessfully installed Pillow-4.1.1 olefile-0.44C:\Users\win7>

相關文章
相關標籤/搜索