mobius
mobius

Reputation: 81

No module named lxml.html

Running OS X 10.9.4, I'm trying to use Scrapy, but I get this error:

Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 3, in <module>
from scrapy.cmdline import execute
File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 8, in <module>
from scrapy.crawler import CrawlerProcess
File "/Library/Python/2.7/site-packages/scrapy/crawler.py", line 6, in <module>
from scrapy.core.engine import ExecutionEngine
File "/Library/Python/2.7/site-packages/scrapy/core/engine.py", line 14, in <module>
from scrapy.core.downloader import Downloader
File "/Library/Python/2.7/site-packages/scrapy/core/downloader/__init__.py", line 13, in <module>
from .middleware import DownloaderMiddlewareManager
File "/Library/Python/2.7/site-packages/scrapy/core/downloader/middleware.py", line 7, in <module>
from scrapy.http import Request, Response
File "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/Library/Python/2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html

And 'pip install lxml' only returns

/Users/username/.virtualenvs/scraper/lib/python2.7/site-packages

Upvotes: 2

Views: 8936

Answers (1)

falsetru
falsetru

Reputation: 369424

It seems like you installed scrapy with system version of Python.

While you installed lxml in virtualenv version of Python.

Check your pip reference which python using following command:

pip -V

If you want install scapy in virtualenv, you need to uninstall scrapy first. Otherwise it will prevent running of virtualenv version because of PATH issue.

deactive  # deactive first, to use system version of python/pip
pip uninstall -y scrapy
hash -r   # refresh program location.

Upvotes: 3

Related Questions