AtuboDad / playwright_stealth

playwright stealth
MIT License
473 stars 57 forks source link

pkg_resources is depreciated. #22

Open jamesrusso opened 7 months ago

jamesrusso commented 7 months ago
>>> import pkg_resources
<stdin>:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
>>> 

This is used here:

def from_file(name):
    """Read script from ./js directory"""
    return pkg_resources.resource_string('playwright_stealth', f'js/{name}').decode()

In 3.12.0 I was getting pkg_resources not found, so perhaps setuptools needs to be a dependency?

Fitmavincent commented 5 months ago

Currently experiencing ModuleNotFoundError: No module named 'pkg_resources' issue when running stealth()

Yangeok commented 4 months ago

Same issue

wadeedmadni commented 3 months ago

Same Issue ModuleNotFoundError: No module named 'pkg_resources'

Any solutions?

Hime-Hina commented 2 months ago

Using importlib.resources.

import importlib.resources

def from_file(name: str):
    """Read script from ./js directory"""
    return (
        importlib.resources.files("playwright_stealth").joinpath("js", name).read_text()
    )
cydan33 commented 1 month ago

I'm having the same issue... Will the paveldudka PR be pushed one day?

LumaC0 commented 3 weeks ago

I've run into this issue a few times, the solution being pip install setuptools

bluenote10 commented 2 weeks ago

Note that installing setuptools is also more of a temporary work-around, and not a very sustainable solution. As per the setuptools docs:

image

Fortunately, the usage of pgk_resources is unnecessary in this case, because accessing relative files is much easier and reliable by using __file__. So #32 is the way to go in my opinion (#24 does the same, but unnecessarily reformats the file).

@AtuboDad It would be great if #32 could be merged and released to PyPI.