Python - programs works in Linux but not in windows - python

I am extending a program that run without any issue in my Linux machine but not in Windows. I need to make it in Windows because the Linux machine has some issues in maintaining the Bluetooth connection.
This the error I am getting:
Traceback (most recent call last):
File "myProject.py", line 106, in <module>
application = Server(options, args)
File "myProject.py", line 42, in __init__
super(Server, self).__init__(options, args)
File "C:\Users\admin\Documents\Python\Server\lib\kernel.py", line 30, in __init__
inject.configure(self.__configure_dependencies)
File "C:\Program Files\Python35\lib\site-packages\inject.py", line 102, in configure
_INJECTOR = Injector(config)
File "C:\Program Files\Python35\lib\site-packages\inject.py", line 230, in __init__
config(binder)
File "C:\Users\admin\Documents\Python\Server\lib\kernel.py", line 58, in __configure_dependencies
module = importlib.import_module(module_source, False)
File "C:\Program Files\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
ImportError: No module named 'src\\myProject_config\\module'
I am sure the problem is with the environment not with the code that is why I did not include any.

I had an issue awhile back on one of my projects when switching from mac to windows. Turns out I just had a more recent version of the language on my windows machine that didn't like the way I did some things, I would first check the versions of your IDE as well as Language, then if they arent matching compiling your program on the linux machine and transferring the compiled version to your windows machine. If it runs fine like that, try to get matching versions of the language.

Related

I'm having an issue with PortAudio building app with py2app

enter code hereI have to update an app I made on an Intel MacBook Pro to an Apple Silicon MacBook Pro. I am having problems after build the app file with py2app. I do not know if it also has to do with MacOS Ventura. I am using python 3.9 and have installed PortAudio with Homebrew
It works perfectly if I run it directly from Terminal but if I run the app I get this lines debugging
/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
myuser#MacBook-Pro-myuser ~ % /Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
Traceback (most recent call last):
File "sounddevice.pyc", line 71, in <module>
OSError: PortAudio library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 170, in <module>
_run()
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 84, in _run
exec(compile(source, path, "exec"), globals(), globals())
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/JFSTOOLS.py", line 27, in <module>
import sounddevice as sd
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "sounddevice.pyc", line 83, in <module>
OSError: cannot load library '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib': dlopen(/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib, 0x0002): tried: '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20), '/System/Volumes/Preboot/Cryptexes/OS/Users/jose/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (no such file), '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20)
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
See the py2app website for debugging launch issues
I have tried to update sounddevice, numpy, portaudio, etc but I am lost as I am not an expert. Any help would be appreciated

ImportError: DLL Load failed while importing LeapPython: The Specified module could not be found

Some Context: I am currently working on a project to communicate between a PyParrot Mambo drone and the Leap Motion Controller. The issue that I am having is that the Leap Motion Controller Software only works in python 2.7 and the PyParrot Mambo Drone is working in Python 3.9. I was able to find a binding for the Leap Motion Controller Software to work with Python 3.7 .When I try to run the Leap Motion code that works in Python 3.7 in Python 3.9 I get an error.
Here is the binding file used to run The Leap Motion Controller in Python 3.7. I get the following error when I run the Sample.py file from the provided folder in python 3.9:
(py39) C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7>python Sample.py
Traceback (most recent call last):
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 565, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1108, in create_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Sample.py", line 9, in <module>
import Leap, sys, time
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 17, in <module>
LeapPython = swig_import_helper()
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 16, in swig_import_helper
return importlib.import_module('LeapPython')
File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.
If someone could provide clarifications on what changes were made between python 3.7 to 3.9 that would cause these errors and a possible fix to make the python 3.7 code compatible with python 3.9. If There is a Leap Motion Software binding for newer versions of python 3 that would also be quite helpful.
The binding was generated with SWIG which does not implement the Python Stable API so you will need to rebuild the binding for each Python Version for this to work with Python 3.9.
This guide was written for Python 3.3.0 but should help to guide you on the process to rebuild this for Python 3.9.

Module not found after building python project by using pysinstaller

I recently finished a project I have been working on for a while. I should present my work on the class' smart board which runs on linux. Taking in mind i can't download its modules because i don't have sudo permission nor it does have internet. So to get around this I decided to build it using pyinstaller. Everything seemed to work just fine in my device, but when i double checked in Virtual box this error pops up.
Traceback (most recent call last):
File "main.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 540, in exec_module
File "matplotlib/__init__.py", line 923, in <module>
File "matplotlib/__init__.py", line 608, in matplotlib_fname
RuntimeError: Could not find matplotlibrc file; your Matplotlib install is broken
[8025] Failed to execute script main
So how can i build it so it works for all devices without the need of installation for any modules
matplotlib requires a config file names matplotlibrc to be found in one of 4 specific locations, the first one being the courant directory (see https://matplotlib.org/tutorials/introductory/customizing.html#the-matplotlibrc-file) One this file prepared as per need it can be embeeded in the exe by adding --add-data=matplotlibrc;. to the build command (replace ; with : for non-Windows systems)

Django Runserver error while executing "Python manage.py runserver"

C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\Scripts\FirstDjango
Proj>python manage.py runserver
Exception ignored in thread started by: <function check_errors.<locals>.wrapper
at 0x00000000038D00D0>
Traceback (most recent call last):
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\core\management\commands\runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\apps\config.py", line 94, in create
module = import_module(entry)
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\importl
ib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\contrib\admin\__init__.py", line 4, in <module>
from django.contrib.admin.filters import (
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\contrib\admin\filters.py", line 10, in <module>
from django.contrib.admin.options import IncorrectLookupParameters
File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\contrib\admin\options.py", line 12, in <module>
from django.contrib.admin import helpers, widgets
SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)
Django version installed successfully-1.11.10
python version-3.8.1
Project created and manage.py as well created.
BUt while i am trying runserver,Throwing an error with this this big passage:
Help me out how can i solve this?
The same happened with me also, but this issue is a minor one as it happens if you have multiple versions of Python on your system, you can select a specific Python version by running python3 or whichever version you want. So you should start from the beginning, uninstall Django first, then create a virtual environment, decide upon a directory where you want to place it, and run the venv module as a script with the directory path:
python3 -m venv tutorial-env
This will create the tutorial-env directory if it doesn’t exist, and also create directories inside it Once you’ve created a virtual environment, you may activate it.
On Windows, run:
tutorial-env\Scripts\activate.bat
On Unix or MacOS, run:
source tutorial-env/bin/activate
Now, In the command prompt, ensure your virtual environment is active, and execute the following command:
py -m pip install Django
NOTE: If django-admin only displays the help text no matter what arguments it is given, there is probably a problem with the file association in Windows. Check if there is more than one environment variable set for running Python scripts in PATH. This usually occurs when there is more than one Python version installed.

pyttsx3 not working on freshly installed windows 10

I have freshly installed windows 10 and I am trying to run the following code.
import pyttsx3;
engine = pyttsx3.init();
engine.say("I will speak this text");
engine.runAndWait() ;
This use to work on my previous windows 10 installation but now it is giving me following error
Traceback (most recent call last):
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ayush/Desktop/sample.py", line 2, in <module>
engine = pyttsx3.init();
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 75, in __init__
self._module = importlib.import_module(name)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
import win32com.client
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: %1 is not a valid Win32 application.
I am using python 3.6.6 64 bit on windows 10.
I have spent many hours trying different solutions like reinstalling python, tried python versions 3.5 and 3.7, reinstalling pyttsx3, also tried solutions given in few related questions but nothing is working.
Thanks in advance
Seems like win32api.pyd (which really is DLL) is not a win32 application. So I think it's loading 64bit drivers to 32bit runtime.
In this case, I will try to uninstall 64bit python, delete it's folder and install a 32bit version. I believe this will solve your problem, since you don't really need 64bit python.
Now the problem is in win32*.pyds, so it seems like your pyttsx3 is 32bit.
According to pypi.org, you can try pip install pypiwin32 to fix both win32 and win32api errors.
I tried installing Python 32 bits but customized with all options available such as a complete library, doing this worked wonders in breaking the errors! Just lauch the .exe launcher again, hit Modify and then just install every option!

Categories

Resources