Error when installing a module with Python pip

I started Python.

It seems that python is something good, so I tried to study machine learning AI Google favorite or unit price ...

So create a Class and learn

Let's create a class in Python.

stu.py


'''
Study class 2017/9/3
create keisuke yamagishi
'''
class Study:

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def callName(self):
        return self.name

    def callAge(self):
        return self.age

stu = Study("qiita", 24)

print stu.callName()
print stu.callAge()

Output result
->> python stu.py 
qiita
24

It will be output like this.

You can pass the value to the constructor and see that the value is reflected properly.

Try Http communication with Python ===== >> [::]

study.py


import requests

class Study:

    def __init__(self,dns="https://google.com"):
        self.dns = dns

    def outputDns(self):
        print "Request: -> %s" % self.dns

    def requestGoogle(self):
        res = requests.get(self.dns)
        print (res)
        print (res.text)

s = Study()
# google Http request
s.outputDns()
s.requestGoogle()

*** ImportError: No module named request ****

I got the above error, so install it with pip

pip install requests
Collecting requests
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
    100% |████████████████████████████████| 92kB 1.3MB/s 
Collecting idna<2.7,>=2.5 (from requests)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 1.5MB/s 
Collecting urllib3<1.23,>=1.21.1 (from requests)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
    100% |████████████████████████████████| 133kB 892kB/s 
Collecting certifi>=2017.4.17 (from requests)
  Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)
    100% |████████████████████████████████| 358kB 1.1MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 2.1MB/s 
Installing collected packages: idna, urllib3, certifi, chardet, requests
Exception:
Traceback (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 install
    **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 ensure_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/idna'

Mmmmm!

It was! !! !!

Permission denied: There is an error on the left!

So ...

I put on sudo ...

sudo pip install requests

The directory '/Users/shichimi/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/shichimi/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting requests
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
    100% |████████████████████████████████| 92kB 2.0MB/s 
Collecting idna<2.7,>=2.5 (from requests)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 4.9MB/s 
Collecting urllib3<1.23,>=1.21.1 (from requests)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
    100% |████████████████████████████████| 133kB 3.1MB/s 
Collecting certifi>=2017.4.17 (from requests)
  Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)
    100% |████████████████████████████████| 358kB 1.5MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 2.5MB/s 
Installing collected packages: idna, urllib3, certifi, chardet, requests
Successfully installed certifi-2017.7.27.1 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22

Succeeded.

And run Python earlier

study.py


->> python study.py
Request: -> https://google.com
<Response [200]>
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="ja"><head><meta content="We provide tools for searching any information in the world. Use the various search functions to find the information you are looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png " itemprop="image"><title>Google</title><script>(function(){window.google={kEI:'UaerWYOEBsv98QX6-JGgCg',kEXPI:'1353383,1353746,1354277,1354297,1354401,1354620,1354625,1354664,1354701,1354748,1354875,1354915,1355158,1355173,1355220,3700301,3700407,3700476,4029815,4031109,4043492,4045841,4048347,4063220,4072777,4076998,4078430,4081039,4081164,4083113,4093313,4095910,4097153,4097469,4097922,4097929,4098733,4098740,4098752,4102109,4102239,4103475,4103861,4104037,4104258,4105114,4105240,4107555,4108458,4109316,4109490,4110115,4110656,4113217,4114574,4115219,4115290,4116244,4116349,4116724,4116731,4116926,4116935,4117980,4118103,4118227,4118627,4118634,4118798,4119121,4119272,4119740,4120285,4120415,4120916,4121035,4121205,4121495,4122262,4122382,4123644,4123862,4124411,4124850,4125209,4125371,4125477,4125837,4125961,4125999,4126200,4126965,4127377,4127391,4127473,4127538,4127728,4128396,4128920,4129308,4129402,4129516,4129843,4129951,10200084,10200095,19003472,19003505,19003509,19003525,19003530,19003531,19003533,19003534',authuser:0,kscs:'c9c918f0_41',u:'c9c918f0'};google.kHL='ja';})();(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI};google.getLEI=function(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b};google.https=function(){return"https:"==window.location.protocol};google.ml=function(){return null};google.wl=function(a,b){try{google.ml(Error(a),!1,b)}catch(c){}};google.time=function(){return(new Date).getTime()};google.log=function(a,b,c,d,g){if(a=google.logUrl(a,b,c,d,g)){b=new Image;var e=google.lc,f=google.li;e[f]=b;b.onerror=b.onload=b.onabort=function(){delete e[f]};google.vel&&google.vel.lu&&google.vel.lu(a);b.src=a;google.li=f+1}};google.logUrl=function(a,b,c,d,g){var e="",f=google.ls||"";c||-1!=b.search("&ei=")||(e="&ei="+google.getEI(d),-1==b.search("&lei=")&&(d=google.getLEI(d))&&(e+="&lei="+d));d="";!c&&google.cached&&-1==b.search("&cached=")&&(d="&cached="+google.cached);a=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+f+"&zx="+google.time()+d;/^http:/i.test(a)&&google.https()&&(google.ml(Error("a"),!1,{src:a,glmm:1}),a="");return a};google.y={};google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};}).call(this);google.f={};var a=window.location,b=a.href.indexOf("#");if(0<=b){var c=a.href.substring(b+1);/(^|&)q=/.test(c)&&-1==c.indexOf("#")&&a.replace("/search?"+c.replace(/(^|&)fp=[^&]*/g,"")+"&cad=h")};</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#36c}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}a.gb1,a.gb2,a.gb3,a.gb4{color:#11c !important}body{background:#fff;color:black}a{color:#11c;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#36c}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoration:underline}a.gb3:hover{text-decoration:none}#ghead a.gb2:hover{color:#fff !important}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#eee;border:solid 1px;border-color:#ccc #999 #999 #ccc;height:30px}.lsbb{display:block}.ftl,#fll a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#ccc}.lst:focus{outline:none}</style><script></script><link href="/images/branding/product/ico/googleg_lodp.ico" rel="shortcut icon"></head><body bgcolor="#fff"><script>(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}
if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
}
})();</script><div id="mngb"> <div id=gbar><nobr><b class=gb1>Search</b> <a class=gb1 href="https://www.google.co.jp/imghp?hl=ja&tab=wi">image</a> <a class=gb1 href="https://maps.google.co.jp/maps?hl=ja&tab=wl">map</a> <a class=gb1 href="https://play.google.com/?hl=ja&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?gl=JP&tab=w1">YouTube</a> <a class=gb1 href="https://news.google.co.jp/nwshp?hl=ja&tab=wn">news</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.co.jp/intl/ja/options/"><u>See more</u> &raquo;</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.co.jp/history/optout?hl=ja" class=gb4>Web history</a> | <a  href="/preferences?hl=ja" class=gb4>Setting</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=ja&passive=true&continue=https://www.google.co.jp/%3Fgfe_rd%3Dcr%26dcr%3D0%26ei%3DUKerWaKLNejd8Ae_uoewBg" class=gb4>Login</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div> </div><center><br clear="all" id="lgpd"><div id="lga"><div style="padding:28px 0 3px"><div style="height:110px;width:276px;background:url(/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png) no-repeat" title="Google" align="left" id="hplogo" onload="window.lol&&lol()"><div style="color:#777;font-size:16px;font-weight:bold;position:relative;top:70px;left:218px" nowrap="">Japan</div></div></div><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%">&nbsp;</td><td align="center" nowrap=""><input name="ie" value="Shift_JIS" type="hidden"><input value="ja" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top" autocomplete="off" class="lst" value="" title="Google Search" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Google Search" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" value="I'm Feeling Lucky" name="btnI" onclick="if(this.form.q.value)this.checked=1; else top.location='/doodles/'" type="submit"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=ja&amp;authuser=0">Searchオプション</a><a href="/language_tools?hl=ja&amp;authuser=0">Language tools</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="fll"><a href="/intl/ja/ads/">Advertising</a><a href="http://www.google.co.jp/intl/ja/services/">Business solution</a><a href="https://plus.google.com/115899767381375908215" rel="publisher">+Google</a><a href="/intl/ja/about.html">About google</a><a href="https://www.google.co.jp/setprefdomain?prefdom=US&amp;sig=__uZyojbLZVEy5-zbV82ltig1txBM%3D" id="fehl">Google.com</a></div></div><p style="color:#767676;font-size:8pt">&copy; 2017 - <a href="/intl/ja/policies/privacy/">privacy</a> - <a href="/intl/ja/policies/terms/">Terms</a></p></span></center><script>(function(){window.google.cdo={height:0,width:0};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script><div id="xjsd"></div><div id="xjsi"><script>(function(){function c(b){window.setTimeout(function(){var a=document.createElement("script");a.src=b;google.timers&&google.timers.load.t&&google.tick("load",{gen204:"xjsls",clearcut:31});document.getElementById("xjsd").appendChild(a)},0)}google.dljp=function(b,a){google.xjsu=b;c(a)};google.dlj=c;}).call(this);(function(){window.google.xjsrm=[];})();if(google.y)google.y.first=[];if(!google.xjs){window._=window._||{};window._DumpException=window._._DumpException=function(e){throw e};google.dljp('/xjs/_/js/k\x3dxjs.hp.en_US.mbPwRuDnBeg.O/m\x3dsb_he,d/am\x3dABg/rt\x3dj/d\x3d1/t\x3dzcms/rs\x3dACT90oHKZL7bVaXyixF_yNex_ga69z5evg','/xjs/_/js/k\x3dxjs.hp.en_US.mbPwRuDnBeg.O/m\x3dsb_he,d/am\x3dABg/rt\x3dj/d\x3d1/t\x3dzcms/rs\x3dACT90oHKZL7bVaXyixF_yNex_ga69z5evg');google.xjs=1;}google.pmc={"sb_he":{"agen":false,"cgen":false,"client":"heirloom-hp","dh":true,"dhqt":true,"ds":"","fl":true,"host":"google.co.jp","isbh":28,"jam":0,"jsonp":true,"msgs":{"cibl":"Searchをクリア","dym":"Maybe:","lcky":"I\u0026#39;m Feeling Lucky","lml":"Details","oskt":"Input tool","psrc":"このSearchキーワードは\u003Ca href=\"/history\"\u003EWeb history\u003C/a\Removed from u003E","psrl":"Delete","sbit":"imageでSearch","srch":"Google Search"},"nds":true,"ovr":{},"pq":"","refpd":true,"refspre":true,"rfs":[],"sbpl":24,"sbpr":24,"scd":10,"sce":5,"stok":"MHNsJ-Xu4AvqZLSKpu5z-NWqrzQ"},"d":{},"aWiv7g":{},"YFCs/g":{}};google.y.first.push(function(){if(google.med){google.med('init');google.initHistory();google.med('history');}});if(google.j&&google.j.en&&google.j.xi){window.setTimeout(google.j.xi,0);}
</script></div></body></html>

I'm done, I'm going to start Python.

Recommended Posts

Error when installing a module with Python pip
A workaround when installing pyAudio with pip.
Error when playing with python
A memorandum when an error occurs with pip install
[python] Error when installing library ramkan
A story about installing matplotlib using pip with an error
Error and solution when installing python3 with homebrew on mac (catalina 10.15)
How to deal with errors when installing Python and pip with choco
A memo for when pip3 is installed with python2.7 for some reason
Installing packages with pip3
Create a Python module
Error with pip install
A memo when creating a python environment with miniconda
I get a Python No module named'encodings' error with the aws command
Install the python module with pip on a server without root privileges
What to do if you get an error when installing python with pyenv
Precautions when installing a hierarchical include directory with waf
Problems when creating a csv-json conversion tool with python
Error handling when installing mecab-python
When moss with pip install
Make a fortune with Python
Create a directory with python
polyfit error when installing matplotlib
What to do if you get an OpenSSL error when installing Python 2 with pyenv
A memo of misunderstanding when trying to load the entire self-made module with Python3
I got a Value Error when using JUMAN ++ with PyKNP
A memo when face is detected with Python + OpenCV quickly
[python] A note when trying to use numpy with Cython
Use a macro that runs when saving python with vscode
After installing CentOS8 with VirtualBox, an error occurs when restarting
What to do if a communication error occurs due to proxy when installing with package management of pip, npm, gem
A story about a python beginner stuck with No module named'http.server'
[Python] What is a with statement?
When coverage fails with _sqlite3 error
Solve ABC163 A ~ C with Python
Operate a receipt printer with python
A python graphing manual with Matplotlib.
Install Python 2.7.9 and Python 3.4.x with pip.
Error when building mac python environment
Python error: ModuleNotFoundError: No module named'flask'
Let's make a GUI with python.
Precautions when installing tensorflow with anaconda
Solve ABC166 A ~ D with Python
Support when installing pillow on python3.9
Create a virtual environment with Python!
I made a fortune with Python.
Building a virtual environment with Python 3
Solve ABC168 A ~ C with Python
Make a recommender system with python
Use blender as a python module
A pretty sloppy Python error solution
[Python] Generate a password with Slackbot
Solve ABC162 A ~ C with Python
Precautions when creating a Python generator
Solve ABC167 A ~ C with Python
Solve ABC158 A ~ C with Python
Let's make a graph with python! !!
When matplotlib doesn't work with python2.7
[Python] Inherit a class with class variables
I made a daemon with Python
Proxy error when running "pip install"