unable to execute VBoxManage command in python executable (created with pyinstaller) - python-3.x

OS: Ubuntu 16.04 LTS
make an install.py file executable:
pyinstaller -w install.py --onefile
install.py script:
import os
VM = os.system('VBoxManage startvm win10 --type headless')
if VM == 0:
print("win10 started...")
else:
print("win10 not started....")
Problem: When I run the python3 install.py on ubuntu terminal it works fine. After that I created it's an executable file with the command mentioned above and when I execute the executable file on the terminal by giving command chmod 777 install & ./install. It gives an error below:
Error:
VBoxManage: error: Failed to create the VirtualBox object!
VBoxManage: error: Code NS_ERROR_FACTORY_NOT_REGISTERED (0x80040154) - Class not registered (extended info not available)
VBoxManage: error: Most likely, the VirtualBox COM server is not running or failed to start.
I don't know what's going wrong python script works fine but when I created it's executable it gives same error every time.
Thanks in advance.

Related

I'm unable to create the .exe for the most simple 'hello world' example

I've used py2exe successfully for previous projects on previous build machines, but now I've freshly installed everything from scratch and can't run the simplest example:
setup.py:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
hello.py:
print("Hello World")
Command: python3 setup.py py2exe
Output:
running py2exe
1 missing Modules
------------------
? _posixshmem imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
Building 'dist\hello.exe'.
error: [WinError 87] The parameter is incorrect.
dest\hello.exe is generated (37 kB!) but gives the following error when run:
Could not locate script resource:The specified resource type cannot be found in the image file.
FATAL ERROR: Could not locate script
The versions I have installed are:
python --version
Python 3.8.6
pip freeze
cachetools==4.1.1
future==0.18.2
numpy==1.19.3
opencv-python==4.4.0.46
pefile==2019.4.18
py2exe==0.10.1.0
pyreadline==2.1
pywin32==300
systeminfo
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.19041 N/A Build 19041
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Hotfix(s): 6 Hotfix(s) Installed.
[01]: KB4580419
[02]: KB4561600
[03]: KB4577266
[04]: KB4580325
[05]: KB4586864
[06]: KB4586781
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
I know that there is clearly something weird happening (I've already hit the issue with 'numpy' here: https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html ) ... but I can't quite see what it is.
Thanks !
-- Mac
You just misstyped the command line flag, should be: python setup.py py2exe.
Works fine for me on Win7, Python 3.8.0:
(py38) λ python setup.py py2exe
running py2exe
2 missing Modules
------------------
? _posixshmem imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
? readline imported from cmd, code, pdb
Building 'dist\hello.exe'.
Building shared code archive 'dist\library.zip'.
Copy c:\users\f3k\envs\py38\scripts\python38.dll to dist
...
Copy DLL C:\Python38\DLLs\libffi-7.dll to dist\
C:\temp
(py38) λ dist\hello.exe
Hello World

building with Pyinstaller not working on Mac OS Catalina

I have had some errors working while with pyinstaller for python 3. I am using Mac OS Catalina. please help me my issue.
print("Hello World")
I'm running the below pyinstaller
pyinstaller --log-level=DEBUG --clean --icon "/Users/projects/hello/build/noun_wooden_wheel_2216564_420.icns" --name hello_world --exclude-module='FixTk' --exclude-module='tcl' --exclude-module='tk' --exclude-module='_tkinter' --exclude-module='tkinter' --exclude-module='Tkinter' --exclude-module='pytest' --onefile -d all --windowed main.py
Here is the error I get after I run the output file
Error loading Python lib '/var/folders/q9/g1d15sw13q5cdspzvpq46mrr0000gn/T/_MEIgYpRBc/Python': dlopen: dlopen(/var/folders/q9/g1d15sw13q5cdspzvpq46mrr0000gn/T/_MEIgYpRBc/Python, 10): no suitable image found. Did find:
/var/folders/q9/g1d15sw13q5cdspzvpq46mrr0000gn/T/_MEIgYpRBc/Python: code signature invalid for '/var/folders/q9/g1d15sw13q5cdspzvpq46mrr0000gn/T/_MEIgYpRBc/Python'
/var/folders/q9/g1d15sw13q5cdspzvpq46mrr0000gn/T/_MEIgYpRBc/Python: stat() failed with errno=3
I'm not even able to run on the machine I built it on.
macOS does not understand one-file bundles, do not use the --onefile flag.

uwsgi plugin "python3" works with Python 3.6 and not with Python3.8

I have the following uwsgi config:
[uwsgi]
callable=app
mount = /labs=/home/vinzee/projectname/app/wsgi.py
manage-script-name = true
touch-reload=/home/vinzee/projectname/app/wsgi.py
socket=/tmp/labshome.sock
processes=5
threads=1
venv=/home/vinzee/.virtualenvs/projectnamevenv38
chdir=/home/vinzee/projectname/app/
plugin=logfile,python3
logger=delete file:/dev/null/c.log
log-route = delete (\] POST \/save => generated )
pythonpath=/home/vinzee/projectname/
The virtual environment specified in venv uses Python3.8. And when reloading uwsgi, I get the classic error:
ModuleNotFoundError: No module named 'flask'
The same error happens when uwsgi's plugin is python and the project uses Python >= 3, as can be seen in this answer.
When I switch to Python3.6, the ModuleNotFoundError disappears and everything works properly.
I already have the package uwsgi-plugin-python3 to the latest version.
How can I get rid of this error for Python3.8? What package do I need to install?
It seems that this is a problem of creating a virtual environment.
virtualenv flask
cd flask
source bin/activate (for activate env )
also you can try to add your python path in wsgi file config
sys.path.append('/home/deployer/anaconda3/lib/python3.5/site-packages')
or
export PYTHONPATH=/root/environments/my_env/lib/python3.6/site-packages/
finally.. run :
python -m flask run

PyInstaller to executable file in lunx, giving : error running upx -v?

I tried to get executable file using PyInstaller on Linux terminal but its throwing error running upx -v. I tried with both .py and .spec file but same error
Same process i tried on windows its worked fine.
I am using :
1. Python : 3.5.7
2. PyInstaller : 3.5.
For more details pleas find check below image
I used below command and its worked
pyinstaller myfile.py --upx-dir=..\upx391w -y --onefile

PyQt4 Installation for windows

I have downloaded PyQt4 for Windows7 from here: https://riverbankcomputing.com/software/pyqt/download
After unzipping the file I've run the command
python configure-ng.py
Unfortunately Iget the following error:
Error: Make sure you have a working Qt qmake on your PATH
How can i fix it?

Resources