Issues with scrapy and anaconda - python

I'm trying to get scrapy installed and working. I have anaconda installed so I deleted the path to python 3.5 from my bash profile but I still get this error. All my dependencies are up to date, including lxml, but I get this when I try to start a project in scrapy.
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 7, in <module>
from scrapy.cmdline import execute
File "/usr/local/lib/python2.7/site-packages/scrapy/__init__.py", line 48, in <module>
from scrapy.spiders import Spider
File "/usr/local/lib/python2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
from scrapy.http import Request
File "/usr/local/lib/python2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/usr/local/lib/python2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html
File "/usr/local/lib/python2.7/site-packages/lxml/html/__init__.py", line 54, in <module>
from .. import etree
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/lxml/etree.so, 2): Library not loaded: libxml2.2.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/lxml/etree.so
Reason: Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

Related

ImportError when trying to import selectorlib

Traceback (most recent call last):
File "/Users/raiyankhan/Desktop/Python projects/web-scraping/main.py", line 2, in <module>
import selectorlib
File "/Users/raiyankhan/Desktop/Python projects/web-scraping/venv/lib/python3.11/site-packages/selectorlib/__init__.py", line 9, in <module>
from .selectorlib import Extractor # noqa:F401
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/raiyankhan/Desktop/Python projects/web-scraping/venv/lib/python3.11/site-packages/selectorlib/selectorlib.py", line 2, in <module>
import parsel
File "/Users/raiyankhan/Desktop/Python projects/web-scraping/venv/lib/python3.11/site-packages/parsel/__init__.py", line 16, in <module>
from parsel.selector import Selector, SelectorList # NOQA
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/raiyankhan/Desktop/Python projects/web-scraping/venv/lib/python3.11/site-packages/parsel/selector.py", line 21, in <module>
from lxml import etree, html
ImportError: dlopen(/Users/raiyankhan/Desktop/Python projects/web-scraping/venv/lib/python3.11/site-packages/lxml/etree.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_exsltDateXpathCtxtRegister'
I reinstalled, upgraded and downloaded all the dependencies of lmxl and libxstl , but it's still not working.
My system is Macbook air m2
OS = MacOS Venture 13.0.1
I was trying to make a program to scrape web information by using the selectorlib module . In pycharm its showing the above error, in vscode it was showing that the module is not found .

ImportError: DLL load failed while importing etree: The parameter is incorrect

I am trying to import and use the docx module but it gives me the following error:
>>> from docx import Document
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
File ".\docx\api.py", line 14, in <module>
from docx.package import Package
File ".\docx\package.py", line 9, in <module>
from docx.opc.package import OpcPackage
File ".\docx\opc\package.py", line 9, in <module>
from docx.opc.part import PartFactory
File ".\docx\opc\part.py", line 12, in <module>
from .oxml import serialize_part_xml
File ".\docx\opc\oxml.py", line 12, in <module>
from lxml import etree
ImportError: DLL load failed while importing etree: The parameter is incorrect.
I am not sure what the problem is because it was working fine before, but suddenly it has started giving this error. I have tried uninstalling and reinstalling lxml, but it didn't change anything. I then uninstalled and reinstalled docx and it gives me this (very similar) error instead:
from docx import Document
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\docx.py", line 17, in <module>
from lxml import etree
ImportError: DLL load failed while importing etree: The parameter is incorrect.
if I try 'pip show lxml' this is the result:
C:\Users\Radha Muthuswamy>pip show lxml
Name: lxml
Version: 4.5.2
Summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Home-page: https://lxml.de/
Author: lxml dev team
Author-email: lxml-dev#lxml.de
License: BSD
Location: c:\users\radha muthuswamy\appdata\local\programs\python\python38-32\lib\site-packages
Requires:
Required-by: docx
I need this software working soon, so please any help would be appreciated, thanks :)

Python error while installing using homebrew

Hi I installed python using "homebrew install python".
A script which was already running started throwing below error.
Traceback (most recent call last):
File "TestConnection.py", line 1, in <module>
from TextUpdater import TextUpdater
File "/Users/gepaul/code/external-tools/tools/Scripts/TextUpdater.py", line 1, in <module>
from GSHelper import GSHelper
File "/Users/gepaul/code/external-tools/tools/Scripts/GSHelper.py", line 2, in <module>
import gspread
File "/Library/Python/2.7/site-packages/gspread/__init__.py", line 21, in <module>
from .client import Client, login, authorize
File "/Library/Python/2.7/site-packages/gspread/client.py", line 19, in <module>
from .httpsession import HTTPSession, HTTPError
File "/Library/Python/2.7/site-packages/gspread/httpsession.py", line 16, in <module>
from http import client
ImportError: cannot import name client
Any Idea why this happened?
Python version is Python 2.7.6

ImportError: cannot import name chardet

Hi i have written a python scraper in which i am importing requests and Beautiful soup module . I am using python2.7 .
I am crating Windows executable (.exe) from my Python script using py2exe module.
For that i have created setup.py as following :
from distutils.core import setup
import py2exe
import requests
packages = [
'requests',
'requests.packages',
'requests.packages.chardet',
'requests.packages.urllib3',
'requests.packages.urllib3.packages',
'requests.packages.urllib3.contrib',
'requests.packages.urllib3.util',
'requests.packages.urllib3.packages.ssl_match_hostname',
]
setup(
console=['CompanyScraper-1.6.py']
)
I have created .exe file by running command "python setup.py py2exe".
But while running the .exe file on window it throwing following error:
Traceback (most recent call last):
File "CompanyScraper-1.6.py", line 13, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
i could not undaerstand why this chardet import error though i have included package into setup.py
Thanks you for looking into my issue.
As you can see from the traceback -
Traceback (most recent call last):
File "CompanyScraper-1.6.py", line 13, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
You have a requests directory with a __init__.py . This is masking the requests package from the library , so when you try to import chardet or any such thing from requests library , it tries to search for it in this local package, and not the library one.
The best solution for this would be to rename the directory and your local package from requests to something else, so that the name does not conflict with any library packages.

ImportError: cannot import name iocpsupport

I am using twisted API and getting following error
Traceback (most recent call last):
File "C:\Documents and Settings\ggne0622\Desktop\Python\google-python-exercises\babynames\SimpleAgent.py", line 16, in <module>
from twisted.internet.iocpreactor import reactor
File "C:\Python27\Lib\site-packages\twisted\internet\iocpreactor\__init__.py", line 8, in <module>
from twisted.internet.iocpreactor.reactor import install
File "C:\Python27\Lib\site-packages\twisted\internet\iocpreactor\reactor.py", line 17, in <module>
from twisted.internet.iocpreactor import iocpsupport as _iocp
ImportError: cannot import name iocpsupport
It looks like you installed Twisted without building the IOCP extensions. Either build them (requires a version of MSVC compatible with your Python installation) or use a binary installer - eg one of the several on https://pypi.python.org/pypi/Twisted

Categories