Permission Denied while trying to run a Python package

梦想的初衷 提交于 2019-12-11 10:29:28

问题


I'm trying to use a Python package called csvkit on an AWS EC2 machine. I was able to install it after some hiccups, which might be related - running pip install csvkit threw an error at

with open(path, 'rb') as stream:
    IOERROR: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/requires.txt'

But I was able to install it with some other command.

Now onto the original problem - when I try to run a simple function within the csvkit package like cavstat, this is the full error output:

[username ~]$ csvstat
Traceback (most recent call last):
  File "/usr/local/bin/csvstat", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 614, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 920, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 815, in resolve
    new_requirements = dist.requires(req.extras)[::-1]
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2552, in requires
    dm = self._dep_map
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2537, in _dep_map
    for extra, reqs in split_sections(self._get_metadata(name)):
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2978, in split_sections
    for line in yield_lines(s):
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2252, in yield_lines
    for ss in strs:
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2566, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1589, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1581, in get_metadata
    return self._get(self._fn(self.egg_info, name))
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1692, in _get
    with open(path, 'rb') as stream:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/requires.txt'

I'm not sure what to even search to see what's the issue. Is this related to date-utils? I'm fairly new to the Linux world, so editing configuration files and whatnot is a bit difficult for me.


回答1:


If you're doing a system-wide install via 'pip install csvkit', you'll need sudo privileges for the current user, which is why the install process has borked on modifying the /usr/local/lib/python2.7 structure.

If you're on an AWS instance you've created, sudo privileges should be pretty straightforward to set up for your current user.

If you're looking for a more contained alternative, you could install virtualenv and set up an isolated virtualenv (https://virtualenv.pypa.io/en/latest/installation.html) but virtualenv might be overkill for a throwaway server.

Does that help at all?



来源:https://stackoverflow.com/questions/32856188/permission-denied-while-trying-to-run-a-python-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!