欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python修炼计划 从基本学起

程序员文章站 2022-07-16 23:24:44
python修炼计划 从基本学起,学习一门热门语言。 计算机语言都是从hello world开始 mac或linux下自带python,windows需要安装,具体安装步骤问度...

python修炼计划 从基本学起,学习一门热门语言。

计算机语言都是从hello world开始

mac或linux下自带python,windows需要安装,具体安装步骤问度娘。

建立python脚本如下,vim helloword.py

#!/usr/bin/python

print "hello, world!";

print "you can't imagine how powerful you are!";

需要加可执行权限,方法是在命令行下输入chmod +x helloworld.py

然后运行./helloworld.py

注意:

在mac下安装pylint可能遇到点问题,

luntekimbp:python apple$ /usr/bin/python -m pip install pylint

/usr/bin/python: no module named pip

解决方法是安装pip,

sudo easy_install pip

这样就可以安装pylint了

安装过程又出现

aluntekimbp:python apple$ /usr/bin/python -m pip install pylint

collecting pylint

using cached pylint-1.7.1-py2.py3-none-any.whl

collecting astroid>=1.5.1 (from pylint)

using cached astroid-1.5.3-py2.py3-none-any.whl

collecting singledispatch; python_version < "3.4" (from pylint)

using cached singledispatch-3.4.0.3-py2.py3-none-any.whl

collecting mccabe (from pylint)

using cached mccabe-0.6.1-py2.py3-none-any.whl

collecting backports.functools-lru-cache; python_version == "2.7" (from pylint)

using cached backports.functools_lru_cache-1.4-py2.py3-none-any.whl

requirement already satisfied: six in /system/library/frameworks/python.framework/versions/2.7/extra

s/lib/python (from pylint)

collecting isort>=4.2.5 (from pylint)

using cached isort-4.2.15-py2.py3-none-any.whl

collecting configparser; python_version == "2.7" (from pylint)

using cached configparser-3.5.0.tar.gz

collecting enum34>=1.1.3; python_version < "3.4" (from astroid>=1.5.1->pylint)

using cached enum34-1.1.6-py2-none-any.whl

collecting lazy-object-proxy (from astroid>=1.5.1->pylint)

using cached lazy-object-proxy-1.3.1.tar.gz

collecting wrapt (from astroid>=1.5.1->pylint)

using cached wrapt-1.10.10.tar.gz

installing collected packages: enum34, singledispatch, lazy-object-proxy, backports.functools-lru-ca

che, wrapt, astroid, mccabe, isort, configparser, pylint

exception:

raceback (most recent call last):

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main

status = self.run(options, args)

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in

run

prefix=options.prefix_path,

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in inst

all

**kwargs

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in

install

self.move_wheel_files(self.source_dir, root=root, prefix=prefix)

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in

move_wheel_files

isolated=self.isolated,

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel

_files

clobber(source, lib_dir, true)

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber

ensure_dir(destdir)

file "/library/python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in en

sure_dir

os.makedirs(path)

file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/os.py", line 157, in

makedirs

mkdir(name, mode)

oserror: [errno 13] permission denied: '/library/python/2.7/site-packages/enum'

这个应该是权限错误。

没办法一个个创建文件夹,比如在/library/python/2.7/site-packages/下执行

sudo mkdir enum

后面的权限报错一样的处理方法,一步步试验,直到安装成功