频道栏目
首页 > 资讯 > Python > 正文

python修炼计划 从基本学起

17-06-13        来源:[db:作者]  
收藏   我要投稿

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

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

相关TAG标签
上一篇:循环链表和约瑟夫环
下一篇:Kotlin学习过程 一 Kotlin插件安装和第一个Kotlin app
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站