OR-Tools CP-Sat with Pyinstaller - pyinstaller

Model works pretty fine on my pc using VS Code. Once I create an exe with pyinstaller and try to run the .exe nothing works. A small window appears for 1 sec and nothing else. I also tried some tk msg box and nothing happens.
Here are the imports of my main :
import csv
import os
import openpyxl
import sft_gen
from ortools.sat.python import cp_model
The imports of my 2nd file (sft_gen):
import csv
from tkinter import Tk
from tkinter.filedialog import askopenfilename
When I run the .exe in the cmd prompt I get :
Error msg in prompt
Edit.1. : After testing, found out that :
from ortools.sat.python import cp_model
is the reason why the .exe fails to execute.
What could be the solution to this? I really want to deploy my CP model to other users... In the meantime I'll try other .exe apps like py2exe and mention here if I have any success with it.

This was asked before.
From what I understand, pyinstaller does not support python module using native libraries.

Related

Pyinstaller not compiling joblib

I've got code that loads a joblib file and works perfectly in my IDE. However when making an exe with pyinstaller it fails. This is some test code:
from joblib import load
print('imported joblib')
load('Repeat.joblib')
When running the exe it successfully imports load, but fails when reading the joblib file. The joblib file is a machine learning model build using scikit learn 0.22.1 and I have joblib 0.14.1.
I've tried everything I can think of. Pyinstaller initially failed with a recursion error but I fixed that using a spec file using
import sys
sys.setrecursionlimit(5000)
Any help?
A, I did find this post about people rolling back Joblib to v0.11 with some success. However that doesn't appear to have resolved your issue.
IT might be an issue with PyInstaller. The key might lie in your `hiddenimports'.
Bounty Source solution

Pycharm Console - Virtual Environment

I just want to: import numpy as np
from my Pycharm console.
I have set up virtual environments.
I can: import numpy as np in my .py code in my projects.
Is there a way to point my console to a virtual environment?
I know I was able to import numpy as np from my console in the past. I do not know how I broke this or how to fix it.

How to import pyFirmata correctly?

I'm working on a project that involves experimenting with Arduino Mega and I'm learning about it from this book https://books.google.co.uk/books/about/Python_Programming_for_Arduino.html?id=O0PfBgAAQBAJ&printsec=frontcover&source=kp_read_button&redir_esc=y#v=onepage&q&f=false
I'm in a stage where I need to import pyfirmata library but for whatever reason it keeps throwing an import error.
I installed the library using pip3 and when that didn't help I built it from source therefore I'm quite confident that I've got it in my system. I even got a file path where it is installed. Within my Python site-packages directory.
The book is favouring Python 2.7 but I figured I can make this work in Python 3 as well. I tried import pyfirmata, from pyfirmata import Arduino and in both cases I get import error.
It shouldn't be that hard to get this to work. What should I try ?
#!/usr/bin/python
# Import required libraries
import pyfirmata
from time import sleep
I also tried replacing the first line with the exact file path of the directory but no effect.
you did everything needed with python but you also need to open Arduino IDE and press files, examples, Firmata, StandardFirmata then transfer the code to your board. Your board will now easily communicate with Python through the module Pyfirmata.

PyQt5 translation: is it possible to run pylupdate5 from Python?

I have some PyQt5 application with some tr() translations in it. I have a Python script that compiles UI forms and resources, and I want it to also update the ts file with translations, because it's a bit annoying to run pylupdate manually each time.
Alas, I haven't find any information, how to run the Python functions that provide translation file compilation in PyQt5. Haven't you ever got the same problem?
I was able to do it like this
import os
ret = os.system("E:\Anaconda3\Library\\bin\\pylupdate5.exe -verbose Main.py otherfile.py thirdfile.py -ts zh_CN.ts")
Hopefully you found it as well

PyQt4 in Mac OS X for Python 3 doesn't seem to work

I installed PyQT4 in Mac OS X El Capitan for Python 3 using the instructions given in this answer. The instructions gave the following commands:
brew install python3
brew install qt
brew install sip --with-python3
brew install pyqt --with-python3
which I run with no problems at all. I then added this line to my .bashrc file:
PYTHONPATH=/usr/local/lib/python3.3/site-packages:$PYTHONPATH
I verified Python 3 was running correcly. I also correctly evaluated the following code within Python 3:
import PyQT4
Now, when I try to run this simple program, nothing happens:
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.show()
After running it, no window opens and nothing happens. I get no error or warning messages. Any ideas of what's going on in here?
This is correct. When you run your code, nothing is supposed to happen, and the application should immediately exit without any errors. Your example translated to C++ will behave identically, too.
Perhaps you wished to spin the event loop? app.exec() will do that.

Resources