python从零安装

一 python

1.安装python

https://www.python.org/

环境变量path添加 ;C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Scripts

2.安装easy_install

https://pypi.python.org/pypi/ez_setup

解压后tar.gz进入目录 python setup.py install

3.安装pip

https://pypi.python.org/pypi/pip

解压后tar.gz进入目录 python setup.py install

4.whl安装方法 pip install “xxxwhl”

二 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.whl
Installing 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.1
You 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 Pillow
Collecting Pillow
  Downloading Pillow-4.1.1-cp36-cp36m-win_amd64.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 441kB/s
Collecting olefile (from Pillow)
  Downloading olefile-0.44.zip (74kB)
    100% |████████████████████████████████| 81kB 900kB/s
Installing collected packages: olefile, Pillow
  Running setup.py install for olefile ... done
Successfully installed Pillow-4.1.1 olefile-0.44

C:\Users\win7>

 
 

 



转载于:https://www.cnblogs.com/my8100/p/5322606.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python是一种高级、解释型、通用型的编程语言,以其简洁易读的语法和丰富的库而受到广泛欢迎。如果你想从开始学习Python,以下是一个基础的教程大纲: 1. **安装Python**:首先,你需要在你的计算机上安装Python。访问官网(https://www.python.org/downloads/)下载适合你操作系统的版本。 2. **学习基本语法**: - 变量与数据类型:Python使用缩进来表示代码块,了解字符串、数字(整数和浮点数)、列表、元组和字典等基本数据类型。 - 基本运算符:包括算术运算、比较运算和逻辑运算。 - 控制流:条件语句(if-else),循环(for和while)。 3. **函数**:函数是可重复使用的代码块,理解如何定义、调用和参数传递。 - 函数定义(def)与返回值。 4. **模块和包**:Python的标准库提供了许多功能模块,如os、math和datetime等。你还需要学会如何导入和使用它们。 5. **面向对象编程**: - 类和对象:定义类,创建对象,并理解封装、继承和多态的概念。 - 特性与方法:属性(变量)和方法(函数)的关系。 6. **Python标准库**:熟悉常用的标准库,如文件操作(io)、网络编程(socket)和异常处理(try-except)。 7. **Python IDE与文本编辑器**:选择一个适合自己的集成开发环境(IDE),如PyCharm、VS Code或Jupyter Notebook。 8. **练习与项目**:通过实际编写小程序,比如计算器、猜数字游戏等,提升编程能力。 9. **学习高级主题**:当你对基础部分有了一定掌握后,可以探索更高级的主题,如装饰器、生成器、迭代器和装饰器等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值