Python学习之mac下PyCharm导入第三方包

  最近对Python有兴趣,在网上搜了《八天深入理解python》视频教程,由于用的mac,不用安装python,感觉瞬间开发环境就已经具备了,然后连个ipython都没装上,ps:还是只刚入手mac的菜鸟。
       在终端,使用:sudo pip install ipython

[plain]  view plain   copy
  print ? 在CODE上查看代码片 派生到我的代码片
  1. Exception:  
  2. Traceback (most recent call last):  
  3.   File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main  
  4.     status = self.run(options, args)  
  5.   File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run  
  6.     prefix=options.prefix_path,  
  7.   File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 736, in install  
  8.     requirement.uninstall(auto_confirm=True)  
  9.   File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 742, in uninstall  
  10.     paths_to_remove.remove(auto_confirm)  
  11.   File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove  
  12.     renames(path, new_path)  
  13.   File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line 267, in renames  
  14.     shutil.move(old, new)  
  15.   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move  
  16.     copytree(src, real_dst, symlinks=True)  
  17.   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree  
  18.     raise Error, errors  
  19. Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/tmp/pip-xR59WP-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]  

报了一堆这样的错误

最后饶了一圈网上方法都说是系统保护(我还没对我的系统做过什么破坏性的事情)

按着:解除系统保护方法如下链接http://chaishiwei.com/blog/994.html

的方法试了好多次,电脑重启10来次,我就是没有实用工具,也是心累。


那么,改用PyCharm的IDE吧

问题来了:同样得导入第三方的包,别人都有file→setting,我这怎么就是没有。也是心累。

在这里记录一下,免得跟多人入坑

1、PyCharm→Preferences→Project:项目名→Project Interpreter


2、点击这个加号可以导入新的库,点击install,这里以requests库为例



3、查看是否已经存在


库已经导入了。


4、写个程序测试一下

[python]  view plain   copy
  print ? 在CODE上查看代码片 派生到我的代码片
  1. import requests  
  2. res=requests.get('https://www.baidu.com')  
  3. savefile=open("itcast.html","w")  
  4. savefile.write(res.content)  
  5. savefile.close()  


生成文件并保存


原文地址:http://blog.csdn.net/zk673820543/article/details/52384134

猜你喜欢

转载自blog.csdn.net/zhonggaorong/article/details/53539956