AtuboDad / playwright_stealth

playwright stealth
MIT License
542 stars 71 forks source link

pkg_resources is depreciated. #22

Open jamesrusso opened 9 months ago

jamesrusso commented 9 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 7 months ago

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

Yangeok commented 7 months ago

Same issue

wadeedmadni commented 6 months ago

Same Issue ModuleNotFoundError: No module named 'pkg_resources'

Any solutions?

Hime-Hina commented 4 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 4 months ago

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

LumaC0 commented 3 months ago

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

bluenote10 commented 3 months 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.

paveldudka commented 1 month ago

Looks like this repo is no longer maintained. We ended up forking it and take over maintenance

https://github.com/tinyfish-io/tf-playwright-stealth New artifact can be installed via:

pip install tf-playwright-stealth