[Eric] Run my project
Detlev Offenbach
detlev at die-offenbachs.de
Sun Nov 11 10:09:05 GMT 2018
Am Sonntag, 11. November 2018, 00:42:27 CET schrieb c.buhtz at posteo.jp:
> Hi,
>
> I was using Python3 on Debian via bash and vim.
> My project runs well on bash. But I am not able to run it via Eric.
>
> The project folder is
> ~/share/work/Feedybus/
>
> The code (py-files) is in
> ~/share/work/Feedybus/feedybus
>
> There are e.g. this files in
> ~/share/work/Feedybus/__init__.py
> ~/share/work/Feedybus/__main__.py
>
> I start the application via the script
> ~/share/work/Feedybus/Feedybus.sh
>
> which content is
>
> #!/bin/bash
>
> cd ~/share/work/Feedybus
> python3 -m feedybus
> exit
>
> So how can I reproduce this with Eric?
> I created a project via eric and all relevant files are in that project.
>
> How should I setup "Project Directory" and "Main Script" in the
> "Project Properties"?
The "Project Directory" should be ~/share/work/Feedybus. The file containing the entry
point into your program (i.e. the main script) should be entered into the "Main Script"
entry. This script is executed by eric's debugger backend. In your case this will probably be
the __main__.py script.
>
> When I click on "Run Project" another dialogs comes up and ask me
> about "Comamndline", "Working directory", "Environment".
> I am not sure what I should put in this fields.
This gives the possibility to run the project with a non-default setup (e.g. with specific
commandline arguments or a different interprter/virtual environment or in a specific
working directory).
>
> When running the project with eric I receive an error about an
> releative import in my __main__.py file.
>
> The debugged program raised the exception unhandled SystemError
> "Parent module '' not loaded, cannot perform relative import"
> File: /home/user/share/work/Feedybus/feedybus/__main__.py, Line: 12
>
> This is line 12
> from .application import FeedybusApplication
Running your script with python3 -m does some setup in the background that makes
relative imports work. However, running the main script directly (i.e. without -m) doesn't
do that and they will fail. To overcome this and make your script more universally usable,
you should tinker with sys.path like that in __init__.py.
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__)))
For more details about this situation see stackoverflow[1] .
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
--------
[1] https://stackoverflow.com/questions/16981921/relative-imports-in-python-3#16985066
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/eric/attachments/20181111/0efe2849/attachment.html>
More information about the Eric
mailing list