0

I am trying to install the web crawling framework Scrapy with the terminal command:

pip install scrapy

and it begins installing and then gives me the following error:

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/pyasn1'

When I try to install with sudo I get the following:

"OSError: [Errno 1] Operation not permitted: '/tmp/pip-kEkq_9-uninstall/System/Library/Frameworks/Python.‌framework/Versions/2‌.7/Extras/lib/python‌​/six-1.4.1-py2.7.egg‌​-info'" 

When I install using a virtual environment in the project folder and try to import the library, it does not recognize the module.

I am unable to discern what I should do to fix this. Any suggestions?

  • Related - [Is it acceptable & safe to run pip install under sudo?](http://stackoverflow.com/questions/15028648/is-it-acceptable-safe-to-run-pip-install-under-sudo) – OneCricketeer Nov 21 '16 at 00:22

1 Answers1

0

It looks like you may be running into an issue installing to /Library. Try running the pip command with sudo or installing to a virtualenv. The virtualenv route is probably the better one.

Daniel Underwood
  • 2,191
  • 2
  • 22
  • 48
  • When I try to install with sudo I get the following: "OSError: [Errno 1] Operation not permitted: '/tmp/pip-kEkq_9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'" –  Nov 21 '16 at 15:12
  • And when I use the virtual environment, it works and I see it in my project folder, but when I try to import scrapy, it says there is no such module. –  Nov 21 '16 at 15:16
  • Are you activating your virtualenv with the script `bin/activate` in the virtualenv you created? – Daniel Underwood Nov 21 '16 at 16:20
  • I am using the `source venv/bin/activate` command –  Nov 21 '16 at 20:15
  • Well that seems a bit weird. Are you able to install with the `--user` flag? Like `pip install --user scrapy`? – Daniel Underwood Nov 21 '16 at 20:29
  • YEESS! Finally it works, thank you very much.. what does the user flag do? –  Nov 21 '16 at 21:32
  • [It installs to a user directory, usually in the home folder.](https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption--user) The virtualenv route should have installed to a virtualenv, which you should have had permission to write to, but didn't for some reason. You can also try the user flag in a virtualenv, but thay shouldn't be necessary when installing to a virtualenv. – Daniel Underwood Nov 21 '16 at 22:10