Comments (15)
I'm getting the exact same error as here: http://stackoverflow.com/questions/26110026/pyinstaller-and-pythonnet-clr
I've tried cx_freeze, py2exe and pyinstaller. I'm using Python 2.7 64bit, Windows 7 64bit. and I have a bunch of .Net frameworks installed, including 4 and 4.5.
Is it at all possible to create an exe that using python.net?
from pythonnet.
@jfbramboll @kelvinomolumo PyInstaller should provide a hook to include pythonnet:
it is reportedly working for people here:
https://groups.google.com/forum/#!topic/pyinstaller/juS48yx3XyE
I am not sure about cx_freeze
from pythonnet.
pyinstaller has been updated to include proper clr (pythonnet) hook:
from pythonnet.
In order to stop crashing with cx_freeze you need to manually add Python.Runtime.dll
file from pythonnet
package to your binary directory.
from pythonnet.
@konstantin-popov does cx_freeze allow configuring hooks for various packages so that this works by default?
from pythonnet.
Not sure, but I think it does, looking at this: https://github.com/anthony-tuininga/cx_Freeze/blob/master/cx_Freeze/hooks.py
from pythonnet.
@konstantin-popov feel free to submit a pull request to cx_freeze to implement this hook based on pyinstaller implementation. We cannot do anything about this in pythonnet without breaking a lot of code.
from pythonnet.
We cannot do anything about this in pythonnet without breaking a lot of code.
Sure. My reply was not a call to action, only a recipe how to deal with this specific problem - actually not with patching cx_freeze, but with adding a file to build using configuration options (option 'include_files').
The ticket you mentioned is actually about a different problem - failing to import custom .NET libraries in frozen app.
from pythonnet.
@konstantin-popov you need to update sys.path in order to custom load your .NET assemblies. See fairly complicated example for pyinstaller here:
from pythonnet.
I do update sys.path and clr.AddReference('customlib')
throws no exceptions - the problem appears later in code when importing the assembly.
I guess pythonnet hooks into python import system to load .NET assemblies, but after freezing the app with cx_freeze in doesn't work for some reason.
from pythonnet.
Is there a traceback available?
from pythonnet.
@konstantin-popov minimum reproducible example would be handy. Also make sure that your library does not reference other custom assemblies, maybe even during runtime.
from pythonnet.
Also make sure that your library does not reference other custom assemblies, maybe even during runtime.
That was exactly the thing. The library was external so I didn't guess it referenced somethine else. Thanks @denfromufa!
P.S. PR with a hook for pythonnet in cx_freeze
from pythonnet.
Pull request merged.
from pythonnet.
@jfbramboll @kelvinomolumo can you please verify that the pythonnet hook is now working in cx_freeze? @anthony-tuininga @konstantin-popov thanks for implementing this!
Anyway if any issues come up we can reopen this issue.
from pythonnet.
Related Issues (20)
- Weird behavior of casting nd.ndarray on different types
- Crash when executing script creating tkinter window multiple times and then closing window
- Model training time increase more than 10x in some case
- PyObject.FromManagedObject(value); does not convert C# bool to Python bool HOT 2
- Importing from DLL works only when namespace != assembly name
- What is the best practice for packaging Python in your application?
- InterfaceObjects cannot address properties outside their declaration HOT 2
- Add to the docs that runtimeconfig.json from a self-contained project is not supported HOT 1
- The model slows down on GPU
- Performance question on List conversion from python to c#.
- Update documentation to reflect API changes HOT 2
- Error line only refers to main code, not imported code from external file HOT 1
- Initialization Error in .NET 8.0.4 HOT 1
- can we have a new release? HOT 2
- Check if the C# methods I am calling within my Python scripts are valid?
- Trying to load a assembly with embedded Assembly inside
- Memory Access Violation - Python Net 3.0.2 - Multi-threaded Dot Net application
- Python Virtual Environment throws error with Python Net 3.0.2
- PythonNet on .NET CORE crashes in IIS HOT 2
- Error when using GridSearchCV n_jobs=-1
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 pythonnet.