您的位置:首页 > 运维架构 > Linux

linux下pip使用可能遇到的问题

2017-07-31 21:17 597 查看
今天想在实验楼上找项目练练手,为了偷懒,linux环境直接就用了win10内置的WSL(Windows内置的Ubuntu子系统,有着比虚拟机更高的系统权限,而且文件目录跟windows下一致)。在使用pip安装pillow库时出现了问题,解决后记录如下:

1、lgc@Orankarl:~/.pip$ sudo pip install pillow
The directory '/home/lgc/.cache/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 '/home/lgc/.cache/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 pillow
python: ../sysdeps/posix/getaddrinfo.c:2591: getaddrinfo: Assertion `(__extension__ ({ const struct in6_addr *__a = (const struct in6_addr *) (sin6->sin6_addr.__in6_u.__u6_addr32); __a->__in6_u.__u6_addr32[0] == 0 && __a->__in6_u.__u6_addr32[1] == 0 && __a->__in6_u.__u6_addr32[2] == __bswap_32 (0xffff); }))' failed.
经过查资料得知,这种问题提示原因是在pip命令中使用了sudo,切换了用户权限,导致user非当前user的情况发生。将sudo去掉即可。要记住,所有pip命令都不要加sudo。

2、lgc@Orankarl:/usr/local/lib/python2.7/dist-packages$ pip install pillow
Collecting pillow
/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning. SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning
Using cached Pillow-4.2.1-cp27-cp27mu-manylinux1_x86_64.whl
Collecting olefile (from pillow)
Using cached olefile-0.44.zip
Installing collected packages: olefile, pillow
Running setup.py install for olefile ... done
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python2.7/dist-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 "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 377, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/bin/createfontdatachunk.py'

从最后一行可以看出,当前用户没有关于目录 /usr/local/bin/的权限,那么就给它权限好了,命令如下:

lgc@Orankarl:/usr/local/bin$ sudo chown -R lgc /usr/local/bin其后如果还有类似错误也如法炮制即可,最终成功安装pillow库。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: