ImportError when trying to import selectorlib - python

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 .

Related

Getting Error even after installing Pyppeteer in Windows

Even after installing pyppeteer in windows using the following commands
pip install pyppeteer
pip install pipenv
pipenv shell
pipenv install pyppeteer
I am still getting this error while executing this command
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
from pyppeteer import launch
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pyppeteer\__init__.py", line 30, in <module>
from pyppeteer.launcher import connect, executablePath, launch, defaultArgs # noqa: E402; noqa: E402
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pyppeteer\launcher.py", line 26, in <module>
from pyppeteer.browser import Browser
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pyppeteer\browser.py", line 11, in <module>
from pyee import EventEmitter
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pyee\__init__.py", line 73, in <module>
from pyee._trio import TrioEventEmitter # noqa
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pyee\_trio.py", line 4, in <module>
import trio
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\trio\__init__.py", line 18, in <module>
from ._core import (
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\trio\_core\__init__.py", line 9, in <module>
from ._exceptions import (
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\trio\_core\_exceptions.py", line 3, in <module>
from trio._util import NoPublicConstructor
ValueError: source code string cannot contain null bytes
Python version used: Python 3.10.6
pyppeteer version installed 1.0.2

Can't run with Face Recognition imported in Python App

When I try to run app.py with Face Recognition imported in Python I get the following error message:
Traceback (most recent call last):
File "app.py", line 10, in <module>
import face_recognition as fr
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/face_recognition/__init__.py", line 7, in <module>
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/face_recognition/api.py", line 4, in <module>
import dlib
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dlib/__init__.py", line 19, in <module>
from _dlib_pybind11 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_png_do_expand_palette_rgb8_neon'
The app will run with the import line commented out. I have CMake, dlib and pip installed. Also trie uninstalling and installing again.

Issues with scrapy and anaconda

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

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.

Categories