ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

Thor Tepper-Garcia
Hi Guys,

I just updated my python 3.6 version to a more recent one, and suddenly I get the error:

ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

when running a Mac App.

From what I could find. apparently the problem is related to the version of
setuptools (was 45 before, is 46 now). According to the discussion here:

https://github.com/pypa/setuptools/issues/1963

A workaround is to compile the code with the flag:

hidden-import='pkg_resources.py2_warn'

And it actually works. However, I find this to be just an ugly solution and I was wondering
whether there is another way to solve this problem?

Cheers,

Thor.

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/b5a980ac-6053-4068-8d2a-1ec00d4cd896%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

bwoodsend
There are a couple of others.

One is to put the following somewhere in your code:
import pkg_resources.py2_warn
Or to make it work as well with older setuptools versions:
try:
   
import pkg_resources.py2_warn
except ImportError:
   
pass

A more satisfactory solution would be to use PyInstaller's hooks which tell PyInstaller contain the hidden-import='pkg_resources.py2_warn' information. The hook for pkg_resources has been updated on github but the changes haven't been released yet. You could upgrade to the developer version on Github or you could manually update that file in your own installation.

Alternatively you can download that hook file and put it somewhere PyInstaller can find it (usually next to your main script).

Brénainn

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/39fde230-b31e-4c7b-ad56-0509da6dbca5%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

Thor Tepper-Garcia
Hi Brénainn,

Thanks a lot, that helps!

Thor.

-----------------------------------------------
Dr. Thorsten Tepper García
Astrophysicist
www.thorsten.mx







> On 21 Apr 2020, at 21:56, bwoodsend <[hidden email]> wrote:
>
> There are a couple of others.
>
> One is to put the following somewhere in your code:
> import pkg_resources.py2_warn
> Or to make it work as well with older setuptools versions:
> try:
>     import pkg_resources.py2_warn
> except ImportError:
>     pass
>
> A more satisfactory solution would be to use PyInstaller's hooks which tell PyInstaller contain the hidden-import='pkg_resources.py2_warn' information. The hook for pkg_resources has been updated on github but the changes haven't been released yet. You could upgrade to the developer version on Github or you could manually update that file in your own installation.
>
> Alternatively you can download that hook file and put it somewhere PyInstaller can find it (usually next to your main script).
>
> Brénainn
>
> --
> You received this message because you are subscribed to the Google Groups "PyInstaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/39fde230-b31e-4c7b-ad56-0509da6dbca5%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/DEA5A996-821E-4299-9EE8-6F6782FF9C0D%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

ankit kumar
In reply to this post by Thor Tepper-Garcia
Hi,
I am getting No module named 'pkg_resources.py2_warn' in pyinstaller when running the exe.
Things that I have tried:
                                   1. Updating the setuptools and pyinstaller (although I am already having the latest ones).
                                   2. Used try except block with pass to ignore exceptions in pyi_rth_pkgres.py and pyimod03_importers.py by taking the reference from one of the post from this forum.
                                   
What I assume is that if I comment out the import statement of dialogflow_v2 in my script it works fine otherwise if I run the exe with dialogflow_v2 import statement, I get below error:

                                                                                File "site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", line 13, in <module>
                                                                                File "c:\users\ankit.bw.kumar\.conda\envs\envforpyqt\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
                                                                                exec(bytecode, module.__dict__)
                                                                                File "pkg_resources\__init__.py", line 86, in <module>
                                                                                ModuleNotFoundError: No module named 'pkg_resources.py2_warn'
                                                                                [17696] Failed to execute script pyi_rth_pkgres.

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/e39d80af-3a8e-4ee6-8f53-9c6f422707db%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: ModuleNotFoundError: No module named 'pkg_resources.py2_warn'

bwoodsend
Now don't take this the wrong way but we've answered this question more times than I can count including on this very conversation. Are these not findable on Google? Are none of them understandable? Do none of them work for you?

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/75ef222c-51eb-4b03-911a-b09b4b8c311d%40googlegroups.com.