configparser error: NoSectionError

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

configparser error: NoSectionError

Thor Tepper-Garcia
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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/30413103-408e-4ebf-a9a7-98c6e03f69b4%40googlegroups.com.

err.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Duane Kaufman
Dear Sir,
Without reviewing the package pynbody myself, does it use an external file for configuration/setup? If it does, has it been included in the pyinstaller process as a dependency?

Sincerely,
Duane

On Thursday, May 7, 2020 at 4:51:44 AM UTC-5, ttepperg wrote:
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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/8a5b56ba-30dd-4fa0-a5de-40658e2b1ecb%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Thor Tepper-Garcia
Dear Duane (if I may),

Thank you for your email.

Pynbody does have a configuration file, which is however contained within its package directory. I’d assume that all of these files are imported by PyInstaller; most likely I’m mistaken.

Do I need to explicitly import this configuration file when creating an executable? If yes, how do I accomplish this?

Thanks in advance for your help!

Thor.

On Thu, 7 May 2020 at 10:17 pm, Duane Kaufman <[hidden email]> wrote:
Dear Sir,
Without reviewing the package pynbody myself, does it use an external file for configuration/setup? If it does, has it been included in the pyinstaller process as a dependency?

Sincerely,
Duane

On Thursday, May 7, 2020 at 4:51:44 AM UTC-5, ttepperg wrote:
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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/8a5b56ba-30dd-4fa0-a5de-40658e2b1ecb%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/CAHit8qMngjBLrHYQX0wcyzqj8Ds58atMhZfdOnFKrLK_38xh1w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Duane Kaufman
Dear Thor,

> Pynbody does have a configuration file, which is however contained within its package directory. I’d assume that all of these files are imported by PyInstaller; most likely I’m mistaken.

I'm not sure pyinstaller simply wraps entire package directories as a group of files, though others may have deeper knowledge.

As a test, you might try just putting a copy of the configuration file next to the pyinstaller .exe, to see if it can find what it needs that way.

There are instructions in the docs for making pyinstaller package extra files into the .exe

Sincerely,
Duane

On Friday, May 8, 2020 at 1:37:02 AM UTC-5, ttepperg wrote:
Dear Duane (if I may),

Thank you for your email.

Pynbody does have a configuration file, which is however contained within its package directory. I’d assume that all of these files are imported by PyInstaller; most likely I’m mistaken.

Do I need to explicitly import this configuration file when creating an executable? If yes, how do I accomplish this?

Thanks in advance for your help!

Thor.

On Thu, 7 May 2020 at 10:17 pm, Duane Kaufman <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="jJeYVHdDCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">duane....@...> wrote:
Dear Sir,
Without reviewing the package pynbody myself, does it use an external file for configuration/setup? If it does, has it been included in the pyinstaller process as a dependency?

Sincerely,
Duane

On Thursday, May 7, 2020 at 4:51:44 AM UTC-5, ttepperg wrote:
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jJeYVHdDCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">pyins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/pyinstaller/8a5b56ba-30dd-4fa0-a5de-40658e2b1ecb%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/pyinstaller/8a5b56ba-30dd-4fa0-a5de-40658e2b1ecb%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/pyinstaller/8a5b56ba-30dd-4fa0-a5de-40658e2b1ecb%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/pyinstaller/8a5b56ba-30dd-4fa0-a5de-40658e2b1ecb%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/7bbd491c-5cef-4523-9e5a-ceb0cb34b2f2%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

bwoodsend
Hi,

> Pynbody does have a configuration file, which is however contained within its package directory. I’d assume that all of these files are imported by PyInstaller; most likely I’m mistaken.
> I'm not sure pyinstaller simply wraps entire package directories as a group of files, though others may have deeper knowledge.

I can confirm that PyInstaller doesn't do anything of the sort I'm afraid. If you compile in 1 dir mode you may see folders inside named after packages such as numpy but that is because a dedicated hook file has been written for that package which explicitly specifies the data files to include and how to structure them.

I imagine your problem is just that config file isn't being bundled. The config filename is specified here in the source code. It uses the __file__ attribute which gets a bit ugly in PyInstaller but I'm fairly certain if you use the following it should work.
--add-data /full/path/to/site-packages/pynbody/default_config.ini;pynbody/default_config.ini

I'm afraid I can't test it as I don't have the compiler necessary to install pynbody but it's something I've had to do with other packages. If it doesn't work, try adding a print statement before the read command in pynbody's source code that prints the filename it is trying to read and post the output here.

Brénainn

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/e610eaed-660c-4b94-9405-d0f7e54389ab%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Thor Tepper-Garcia
In reply to this post by Duane Kaufman
Dear Duane,

Thanks for your reply.


> As a test, you might try just putting a copy of the configuration file next to the pyinstaller .exe, to see if it can find what it needs that way.
Unfortunately, that did not work. I also try explicitly importing the module within my python script; without success…

> There are instructions in the docs for making pyinstaller package extra files into the .exe
I’ll look into that, although on a quick read I could not find the information.

Thanks anyways,

Thor.

____________________________
Dr. Thorsten Tepper García
Astrophysicist
www.thorsten.mx
@thorsten_mx

--
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/FE2A99D8-4A84-497D-B1C8-44B4E275FE59%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Thor Tepper-Garcia
In reply to this post by Thor Tepper-Garcia
I have solved the issue.

It might be useful in other circumstances; I'm more than happy to provide
the details if anyone is interested.


On Thursday, May 7, 2020 at 7:51:44 PM UTC+10, ttepperg wrote:
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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/40d8694b-41a2-4fb9-aa88-8d5c88b5626f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Duane Kaufman
Dear ttepperg,

If it is not too hard to do, a quick overview of what you had to do to fix this problem may help someone in the future.

Sincerely,
Duane

On Wednesday, May 20, 2020 at 1:56:49 AM UTC-5, ttepperg wrote:
I have solved the issue.

It might be useful in other circumstances; I'm more than happy to provide
the details if anyone is interested.


On Thursday, May 7, 2020 at 7:51:44 PM UTC+10, ttepperg wrote:
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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/ec9c2499-b53f-4a0b-8801-4bdaf15247b2%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

Thor Tepper-Garcia
Dear Duane, Brénainn,

I did essentially what Brénainn suggested, although I did not see their reply until now; so I figured it out myself, and very much the hard way ;)
I simply copied the file config.ini file into my script’s dir and used the flag —add-data config.ini:pynbody

The trick is, as Brénainn mentioned, to understand that the dir structure of packages within the Python dist are mirrored by the temporary dir created at runtime. So my app was looking for the file within the <temp dir path>/pynbody but it was not there; also, —add-data config.ini:. did not help as this was binding the file into the parent dir.

Hope this helps others in similar situations.

Thor.

On Wed, 20 May 2020 at 10:16 pm, Duane Kaufman <[hidden email]> wrote:
Dear ttepperg,

If it is not too hard to do, a quick overview of what you had to do to fix this problem may help someone in the future.

Sincerely,
Duane

On Wednesday, May 20, 2020 at 1:56:49 AM UTC-5, ttepperg wrote:
I have solved the issue.

It might be useful in other circumstances; I'm more than happy to provide
the details if anyone is interested.


On Thursday, May 7, 2020 at 7:51:44 PM UTC+10, ttepperg wrote:
Hi,

With the simplest script possible that only contains the following statement:

import pynbody

I get a weird error when trying to run the exe file (error message attached).


Pynbody is a library installed in a standard location, the same one in which
PyInstaller resides. Needless to say, I don't have the problem when running
the script from source (or any other more meaningful script using this library),
so the problem is happening at runtime.

I'm using PyInstaller 3.5 with Python 3.6 on a Mac (High Sierra).

Thanks a lot in advance for your help!

--
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/ec9c2499-b53f-4a0b-8801-4bdaf15247b2%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/CAHit8qNWqCBbhDthd6Awy5KhxgQ75t2Zd68RtKr8mrUg1mPLsg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: configparser error: NoSectionError

bwoodsend
 Hi Thor, thanks for sharing that.

I've written a PyInstaller hook based on what you've said. Could you road-test it for me? Download it from here.

To do this, download the hook, then add its parent folder as a hook dir using the `--additional-hooks-dir=folder` option. With this hook, you should be able to omit your `--add-data` and remove the copied .ini file without anything breaking. If it works then we can add it to PyInstaller permanently so that no-one ever has to fix this again.

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/bf8e6422-28ed-4034-9587-339fb94cd814%40googlegroups.com.