Comments (21)
@artem3k with my fix, workarounds should not be necessary anymore, but all forms are supposed to work. Of course, specifying the path indeed avoids the problematic code, but I am not sure your variant does it, anyway, changing the code is never the preferred solution in Nuitka, we want to be 100% compatible with these kind of packages.
from nuitka.
@KevinRodriguez777 can you confirm this? dotenv rings a bell though, probably it's complaing about a lack of config file there.
from nuitka.
@KevinRodriguez777 can you confirm this? dotenv rings a bell though, probably it's complaing about a lack of config file there.
it's failing here https://github.com/theskumar/python-dotenv/blob/d6c0b9638349a7dd605d60ee555ff60421c1a594/src/dotenv/main.py#L302-L306
it's not a config file issue, it's a problem when using load_dotenv()
from nuitka.
i could PR dotenv and do something like this
if usecwd or _is_interactive() or getattr(sys, 'frozen', False):
# Should work without __file__, e.g. in REPL or IPython notebook.
path = os.getcwd()
elif "__compiled__" in globals():
# For Nuitka compiled programs, use the directory of the main script
path = os.path.dirname(sys.executable)
or we could handle it from the YAML or nuitka side, what do you think?
from nuitka.
I think __compiled__.containing_dir
is the better choice, it works independent of modes, e.g. app bundles, module mode, onefile, etc. and is preferable to manual guessing. I added it only recently.
.. important::
What you should **not** do, is use the current directory
``os.getcwd``, or assume that this is the script directory, e.g. with
paths like ``data/``.
If you did that, it was never good code. Links, to a program,
launching from another directory, etc. will all fail in bad ways. Do
not make assumptions about the directory your program is started
from.
In case you mean to refer to the location of the ``.dist`` folder for
files that are to reside near the binary, there is
``__compiled__.containing_dir`` that also abstracts all differences with
``--macos-create-app-bundle`` and the ``.app`` folder a having more
nested structure.
.. code:: python
# This will find a file *near* your app or dist folder
try:
open(os.path.join(__compiled__.containing_dir, "user-provided-file.txt"))
except NameError:
open(os.path.join(os.path.dirname(sys.argv[0]), "user-provided-file.txt"))
What is the original code like from dotenv there?
from nuitka.
while frame.f_code.co_filename == current_file or not os.path.exists(
frame.f_code.co_filename
):
assert frame.f_back is not None
frame = frame.f_back
frame_filename = frame.f_code.co_filename
path = os.path.dirname(os.path.abspath(frame_filename))
the problem is that it was failing due to this. the source is linked above
from nuitka.
Oh, os.path.exists(...co_filename)
is going to be false a lot for Nuitka. I guess, it wants to find the frame upwards, that lives in a different file.
inspect.getmodule(os.path.basename.code)
<module 'posixpath' from '/usr/lib/python3.10/posixpath.py'>
That makes me assume this would be a good replacement:
while inspect.getmodule(frame.f_code) is inspect.getmodule(sys._getframe()):
frame = frame.f_back
That is however only beauty I guess.
With the existence check, it probably wants to get rid of import bootstrap ones, which I think are better done with a .startswith() on the module __name__
maybe. So
not os.path.exists(
frame.f_code.co_filename
)
could likely be replaced with
inspect.getmodule(frame.f_code).startswith("importlib"
Multi-line strings are a bit difficult in yaml, but doable with the |
notation. So far, we use them only for replacement values, but maybe there is an example how to use it for the key in the replacement_plain dict.
from nuitka.
Hello!
Although I don't quite understand what you are discussing, may I ask if my question has already found a solution?
Or what should I do now to solve this problem?
Thank you.
from nuitka.
Hello!
You can temporarily bypass using find_dotenv.
if dotenv_path is None and stream is None:
dotenv_path = find_dotenv()
load_dotenv() -> no work
load_dotenv('.env') -> work
from nuitka.
hi
@artem3k
Where should I add the judgment code you mentioned? Adding the judgment code as you said in my code will cause errors.
NameError: name 'dotenv_path' is not defined
thank
from nuitka.
Please allow me to criticize this issue. There are not even pip package names provided, that are required to run the example. When I do it, I get an error like this:
File "C:\Users\kayha\repos\Py2C\Mini2.py", line 28, in login
driver = webdriver.Edge(EdgeChromiumDriverManager().install(), options=option)
TypeError: WebDriver.__init__() got multiple values for argument 'options'
The example is asking choices, I do not want prompts in minimal examples, I want straight out errors, that are unique to the code.
from nuitka.
For the dotenv part, I updated our workaround to their new (bad) code. Previously they insisted on package directories to exist (which they do not with compiled code in all cases), and now they want filenames of Python files to exist, which they definitely do not with Nuitka. With that, I am getting the same error when selecting Edge as with the example script.
from nuitka.
Thanks for your report, this is fixed on the factory branch, which is a development version under rapid development. You can try it out by going here: https://nuitka.net/doc/factory.html
Feedback if this is working is very welcome, just please do not share plans of doing it, but rather confirmations or denials of it working.
from nuitka.
@kayhayen
Hello, I have used this command to update to the development version.
python -m pip install -U --force-reinstall "https://github.com/Nuitka/Nuitka/archive/factory.zip"
The displayed version is
Successfully installed Nuitka-2.2rc2 ordered-set-4.1.0 zstandard-0.22.0
I use this command to package the exe.
nuitka --standalone --show-memory --show-progress --follow-import-to=need --output-dir=o --nofollow-imports test.py
An error occurred.
log.log
from nuitka.
@c469591 Sorry, I misled you. The code above is a snippet from the dotenv code. A temporary solution is simply to specify the path load_dotenv('.env')
from nuitka.
@c469591 that was a regression of factory, that I fixed only now, please retry
from nuitka.
@kayhayen
Succeeded, the exe file can now run normally.
However, the time it takes to package into an exe file is particularly long, taking nearly 10 minutes. Is there a way to shorten the packaging time for exe files?
thank
from nuitka.
Yes, but this is not a personal support thread.
from nuitka.
@kayhayen
Could you please tell me if individual support services require the purchase of a subscription? Or where should I inquire about it?
thank
from nuitka.
@c469591 https://nuitka.net/doc/commercial.html and there is a form if it doesn't answer your questions
from nuitka.
This part of the 2.1.3 release I just made.
from nuitka.
Related Issues (20)
- Downloaded MinGW64 is not usable when home directory path is non-DOS HOT 3
- Unable to open project after converting QML file to pyd and compiling with UPX HOT 1
- Standalone: Standard library scan can crash with .git folders present HOT 5
- Error while compiling project with Yaml config file HOT 4
- RecursiveScriptModule' has no attribute '_construct HOT 1
- Virus total 29/72 antiviruses say my program compiled with Nuitka has virus HOT 5
- ModuleNotFoundError: No module named `scipy.special._cdflib` with `SciPy-1.13.0` HOT 4
- supoortability of @Slot(name="xxx") HOT 1
- Nuitka scanning for executables does not ignore directories of the same name (was locating GCC wrong) HOT 7
- get RuntimeError when use getattr() to get a non-exist attribute on asgiref.local.Local HOT 6
- Build imgui-bundle example successfully into excutable, but crashed at getting windows WndProc hook HOT 14
- compile standalone, incorrect __file__ variable HOT 7
- SetConsoleCtrlHandler not working with console HOT 7
- Nuitka-Scons: Non downloaded winlibs-gcc 'H:\MinGW\bin\gcc.exe' is being ignored, Nuitka is very dependent on the precise one. HOT 4
- Packaging mlc-llm HOT 3
- Are Nuitka compiled files actually binaries ? HOT 1
- Problem error ModuleNotFoundError: No module named 'sspilib.raw._text' HOT 9
- [ERROR] Failed to add resources to file 'myUiExample.exe' HOT 1
- ImportError: Could not find library zaber-motion-lib-windows-amd64.dll in bindings HOT 17
- ModuleNotFoundError: No module named 'aspose.threed.formats'; 'aspose.threed' is not a package HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuitka.