Coder Social home page Coder Social logo

Comments (18)

Rapid1898-code avatar Rapid1898-code commented on June 2, 2024 5

Hello - i think with this command when creating the executeable on MacOS i get rid of the error message:
pyinstaller --onefile --collect-datas=fake_useragent myprg.py

from fake-useragent.

ElysianeYue avatar ElysianeYue commented on June 2, 2024 1

Hello - i think with this command when creating the executeable on MacOS i get rid of the error message: pyinstaller --onefile --collect-datas=fake_useragent myprg.py

ohh,thank u. with the method you offered ,i solve it too!

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

Interesting. Which python version are you using, if I may ask? On which os?

from fake-useragent.

 avatar commented on June 2, 2024

python3.8 pyinstaller is packaged and run in win2008 server

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

hm.. I think pyinstaller can't handle importlib-resources package. I will try to fallback to pkg_resources, lets hope this works.. Otherwise I don't know either

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

I tried to impl. a fallback mechanism towards pkg_resource before going to the external website resource. Hopefully this will fetch the data file locally still.

This is available in version 1.1.0.

Update via: pip install --upgrade fake-useragent

from fake-useragent.

JimCarry455 avatar JimCarry455 commented on June 2, 2024

it was working fine for me till the last update now i am getting the same error as he got it was working fine before the update i got this one https://i.imgur.com/WX5ix1a.png
:/ @Danger89

from fake-useragent.

JimCarry455 avatar JimCarry455 commented on June 2, 2024

i solved it by writing this i don't know what was the problem (ua = UserAgent(use_external_data=True))

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

it was working fine for me till the last update now i am getting the same error as he got it was working fine before the update i got this one https://i.imgur.com/WX5ix1a.png :/ @Danger89

Why is your Python looking in the AppData\\Local\\Temp folder? Did you correctly installed Python and pip? This seems not a normal way of using Python.

image

I would expect that the Python is looking at the following folder instead: C:\\Users\\Yourname\\AppData\\Local\\Packages.


ua = UserAgent(use_external_data=True)

Yea, that is how you skip reading the local JSON data file all together. Which is maybe not ideal. That being said, even with those errors, it automatically fallback to retrieving the external data. So for example ua.random will still output data, despite the warnings.

from fake-useragent.

JimCarry455 avatar JimCarry455 commented on June 2, 2024

Yea i have installed python and pip correctly it only does this after using pyinstaller and yea it continue after giving the error

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

Ah you are both using pyinstaller. Hm did might me a clue. Maybe pyinstaller can't be used together with resource files, in order to retrieve this locally installed data file.

from fake-useragent.

 avatar commented on June 2, 2024

win 2008 server The code version can be run directly
pyinstaller Error reported after packaging
Unable to find local data/json file or could not parse the contents using import
lib-resources. Try pkg-resource next.
Traceback (most recent call last):
File "fake_useragent\utils.py", line 128, in load
File "importlib_resources_common.py", line 22, in files
File "importlib_resources_common.py", line 53, in get_package
File "importlib_resources_common.py", line 44, in resolve
File "importlib_init_.py", line 126, in import_module
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in find_and_load_unlocked
ModuleNotFoundError: No module named 'fake_useragent.data'
Could not find local data/json file or could not parse the contents using pkg-re
source. Fallback to external resource.
Traceback (most recent call last):
File "fake_useragent\utils.py", line 128, in load
File "importlib_resources_common.py", line 22, in files
File "importlib_resources_common.py", line 53, in get_package
File "importlib_resources_common.py", line 44, in resolve
File "importlib_init
.py", line 126, in import_module
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'fake_useragent.data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "fake_useragent\utils.py", line 143, in load
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\ADMINI~1\Ap
pData\Local\Temp\_MEI24282\fake_useragent\data\browsers.json'
Traceback (most recent call last):
File "urllib\request.py", line 1318, in do_open
File "http\client.py", line 1239, in request
File "http\client.py", line 1285, in _send_request
File "http\client.py", line 1234, in endheaders
File "http\client.py", line 1026, in _send_output
File "http\client.py", line 964, in send
File "http\client.py", line 1400, in connect
File "ssl.py", line 407, in wrap_socket
File "ssl.py", line 814, in init
File "ssl.py", line 1068, in do_handshake
File "ssl.py", line 689, in do_handshake
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c
:841)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "fake_useragent\utils.py", line 54, in get
File "urllib\request.py", line 223, in urlopen
File "urllib\request.py", line 526, in open
File "urllib\request.py", line 544, in _open
File "urllib\request.py", line 504, in _call_chain
File "urllib\request.py", line 1361, in https_open
File "urllib\request.py", line 1320, in do_open
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certifica
te verify failed (_ssl.c:841)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "fake_useragent\utils.py", line 166, in load
File "fake_useragent\utils.py", line 89, in get_browser_user_agents_online
File "fake_useragent\utils.py", line 74, in get
fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "测试.py", line 4, in
File "fake_useragent\fake.py", line 59, in init
File "fake_useragent\fake.py", line 75, in load
File "fake_useragent\utils.py", line 169, in load
fake_useragent.errors.FakeUserAgentError: Could not load data from external webs
ite
[1556] Failed to execute script '测试' due to unhandled exception!

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

In your case Python is also looking at C:\Users\<your user>\AppData\Local\Temp\_MEI24282\fake_useragent\data\browsers.json.. Why would Python look into the Temp folder?

I don't have a Windows machine, I have definitely also not a Win 2008 machine. I also never used pyinstaller to be honest.

from fake-useragent.

Rapid1898-code avatar Rapid1898-code commented on June 2, 2024

Hello - when i package the solution with pyinstaller - i also get this error
ModuleNotFoundError: No module named 'fake_useragent.data'
with the new version
fake-useragent 1.1.0

Is there a suggested way to fix this?

from fake-useragent.

Rapid1898-code avatar Rapid1898-code commented on June 2, 2024

Hello - i get the below error message when running the executeable on MacOS which i create with pyinstaller -
(the programs runs trough - but gives this error message at the beginning - it seems

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
PolziMacs-Mini:~ polzimac$ /Users/polzimac/Documents/DEV/Fiverr/ORDER/robalf/checkMapsSel2 ; exit;
Pls provide name of excel: 
Working on checkMaps.xlsx
Checking Browser driver...
Unable to find local data/json file or could not parse the contents using importlib-resources. Try pkg-resource next.
Traceback (most recent call last):
  File "fake_useragent/utils.py", line 128, in load
  File "importlib_resources/_common.py", line 46, in wrapper
  File "importlib_resources/_common.py", line 56, in files
  File "functools.py", line 877, in wrapper
  File "importlib_resources/_common.py", line 82, in _
  File "importlib/__init__.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'fake_useragent.data'
Could not find local data/json file or could not parse the contents using pkg-resource. Fallback to external resource.
Traceback (most recent call last):
  File "fake_useragent/utils.py", line 128, in load
  File "importlib_resources/_common.py", line 46, in wrapper
  File "importlib_resources/_common.py", line 56, in files
  File "functools.py", line 877, in wrapper
  File "importlib_resources/_common.py", line 82, in _
  File "importlib/__init__.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'fake_useragent.data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fake_useragent/utils.py", line 142, in load
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/q1/288l_zvn2sl7_lx4cv34yz3m0000gn/T/_MEIVFKdST/fake_useragent/data/browsers.json'
v1_0 https://www.google.com/maps/search/http%3A%2F%2Fwww.biorochelou.com written to row 6...
v1_0 https://www.google.com/maps/search/http%3A%2F%2Fwww.giovannirana.it written to row 7...
Program finished - pls press <enter> to close the window...
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

from fake-useragent.

melroy89 avatar melroy89 commented on June 2, 2024

Should I document something on the Readme or?

from fake-useragent.

kingofnorth1 avatar kingofnorth1 commented on June 2, 2024

您好 - 我认为在 MacOS 上创建可执行对象时使用此命令,我摆脱了错误消息: pyinstaller --onefile --collect-datas=fake_useragent myprg.py

thank u, i Solved this problem

from fake-useragent.

liqwang avatar liqwang commented on June 2, 2024

Hello - i think with this command when creating the executeable on MacOS i get rid of the error message: pyinstaller --onefile --collect-datas=fake_useragent myprg.py

Thanks a lot! It works for me
I didn't get the error when creating the executeable, instead, I got the error when running the executeable

My environment is:

  • windows 10 x64
  • pyinstaller v6.3.0
  • fake-useragent v1.4.0

from fake-useragent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.