Jupyter Notebook Octave Kernel: %1 is not a valid Win32 application - python

I recently started working with Octave on Jupyter notebook. I was previously working on a Linux laptop but then I thought about creating a similar working environment on my Windows laptop. I followed more or less the same approach.
I already have Octave installed on my Windows laptop and I have added C:\Program Files\GNU Octave\Octave-6.1.0\mingw64\bin to the PATH environment variable. I also have set OCTAVE_EXECUTABLE to octave-cli in the environment variables.
I created a virtual environment using the following command.
python -m venv octave
Then I activated the virtual environment from the desired working directory and installed Jupyter in it using the following command.
pip install jupyter
Then I installed the Octave kernel using the following command.
pip install octave-kernel
After that, when I ran the following command to see if things are working or not I got the error mentioned further below.
(octave) λ python -m octave_kernel.check
Octave kernel v0.32.0
Metakernel v0.27.5
Python v3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
Python path: C:\Workspace\python-virtual-environments\octave\Scripts\python.exe
Connecting to Octave...
Octave connection established
[WinError 193] %1 is not a valid Win32 application
When I start jupyter-notebook and open a notebook, I end up getting the same error.
[I 15:20:33.465 NotebookApp] Kernel started: 92de579a-c8df-4cf8-9ec4-dbb9aefa1fe5, name: octave
[MetaKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\ipykernel\kernelbase.py", line 265, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\ipykernel\kernelbase.py", line 655, in kernel_info_request
content.update(self.kernel_info)
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\ipykernel\kernelbase.py", line 648, in kernel_info
'language_info': self.language_info,
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 78, in language_info
'version': self.language_version,
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 69, in language_version
ver = self.octave_engine.eval('version', silent=True)
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 96, in octave_engine
logger=self.log)
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 173, in __init__
self.repl = self._create_repl()
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\octave_kernel\kernel.py", line 392, in _create_repl
force_prompt_on_continuation=True)
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\metakernel\replwrap.py", line 63, in __init__
encoding="utf-8")
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\metakernel\pexpect.py", line 32, in spawn
encoding=encoding, codec_errors=codec_errors)
File "c:\workspace\python-virtual-environments\octave\lib\site-packages\pexpect\popen_spawn.py", line 53, in __init__
self.proc = subprocess.Popen(cmd, **kwargs)
File "C:\Program Files\Python36\lib\subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python36\lib\subprocess.py", line 1017, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
What am I doing wrong here?
Update #1
I tried changing the OCTAVE_EXECUTABLE environment variable to octave but I got the following error.
(octave) λ python -m octave_kernel.check
Octave kernel v0.32.0
Metakernel v0.27.5
Python v3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
Python path: C:\Workspace\python-virtual-environments\octave\Scripts\python.exe
Connecting to Octave...
Octave connection established
OCTAVE_EXECUTABLE does not point to an octave-cli file, please see README

It looks like the kernel used does not work with Octave 6. I had the same problem with Octave 6.2.0. OCTAVE_EXECUTABLE and PATH were set correctly according to installation instructions, but without success. The octave kernel chek error message is: [WinError 193] %1 is not a valid Win32 application.
But with Octave 5.2 everything works fine. I work with jupyter under winpython 3.9.2
Problem resolved.
Octave 6.2.0 and winpython 3.9.4 completely reinstalled. Path and environment variable set:
Path —>D:\Octave\Octave-6.2.0\mingw64\bin
OCTAVE_EXECUTABLE —> D:\Octave\Octave-6.2.0\mingw64\bin\octave-cli.exe
now it works suddenly without errors with Octave 6.2.0.
The only difference from the previous installation is winpython 3.9.4 instead of 3.9.2

Related

Stable Diffusion 1.5, 2.0 webui-user.bat not found launch error in cmd [WinError 2]

Went through the instructions of installing git, python of both Stable Diffusion 1.5 and 2.0
(https://medium.com/geekculture/a-simple-way-to-run-stable-diffusion-2-0-locally-on-your-pc-no-code-guide-3beb911e444c guide for latest I used)
and both don't work out on moment when I open webui-user.bat which is located in my
C:\SD2\stable-diffusion-webui-master
When launch webui-user.bat it says
Windows can't find "C:\SD2\stable-diffusion-webui-master\webui-user.bat"
```- the very file I just clicked
When I launch cmd in that dir and try to use
PS C:\SD2\stable-diffusion-webui-master> python launch.py
that what it gives to me:
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: <none>
Installing torch and torchvision
Traceback (most recent call last):
File "C:\SD2\stable-diffusion-webui-master\launch.py", line 360, in <module>
prepare_environment()
File "C:\SD2\stable-diffusion-webui-master\launch.py", line 269, in prepare_environment
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
File "C:\SD2\stable-diffusion-webui-master\launch.py", line 87, in run
result = subprocess.run(command, shell=True, env=os.environ if custom_env is None else custom_env)
File "C:\Users\Sougo\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\Sougo\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Sougo\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
PS C:\SD2\stable-diffusion-webui-master>
How do I fix?
I tried installing/uninstalling different Pythons: Python 3.10.6 for SD 1.5 and 3.11 for the 2.0 both leave the same issue. I tried changing
shell=True in that subprocess.py file
but didn't change anything as well
It uploads git repo with no problem, but
FileNotFoundError: [WinError 2] The system cannot find the file specified
is hard to get fix. I saw another variant of virtual machines cmd - but didn't even get how to open that cmd, I doubt I have it causing issue

How to compile the resources.qrc file with pyrcc5

I am trying to make a plugin for QGIS 3(I am using Windows 10) but before it is created one step before it shows this message :
"The resource compiler pyrcc5 was not found in your path. You'll have to manually compile the resources .qrc file with pyrcc5 before installing your plugin".
This is a setback because after setting a plugin path in pyqgis it deploys but the plugin says it cannot find the class module.
I have managed to make a plugin but it says error when calling its classFactory() method thus i think this is because I fail to compile the pyrcc5.
It brings this error upon after selecting it couldn't load plugin 'remove_feature' due to an error when calling its classFactory() method :
ModuleNotFoundError: No module named 'remove_feature.resources'
Traceback (most recent call last):
File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 335, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\remove_feature\__init__.py", line 35, in classFactory
from .Remove_feature import Remove_feature
File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\remove_feature\Remove_feature.py", line 29, in
from .resources import *
File "C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'remove_feature.resources'
Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.4.5-Madeira Madeira, 89ee6f6e23
Python Path:
C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python
C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python/plugins
C:\Program Files\QGIS 3.4\bin\python37.zip
C:\PROGRA~1\QGIS3~1.4\apps\Python37\DLLs
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib
C:\Program Files\QGIS 3.4\bin
C:\PROGRA~1\QGIS3~1.4\apps\Python37
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\win32
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\Pythonwin
C:/Users/Arnold Kilaini M/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\Arnold Kilaini M\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\mmqgis/forms
From the OSGeo4W Shell, run qt5_env.bat and py3_env.bat.
Then, change the directory to
C:\Users\Arnold Kilaini M\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\mmqgis".
Run pyrcc5 -o resources.py resources.qrc
Also, I found the link to a gis.stackexchange question related to yours:
Hope this helps!
With this .bat I don't have any problem aymore.
#echo off
SET QGIS_ROOT=C:\GIS\QGIS
call "%QGIS_ROOT%"\bin\o4w_env.bat
call "%QGIS_ROOT%"\apps\grass\grass78\etc\env.bat
path %PATH%;%QGIS_ROOT%\apps\qgis\bin
path %PATH%;%QGIS_ROOT%\apps\grass\grass78\lib
path %PATH%;C:\GIS\QGIS\apps\Qt5\bin
path %PATH%;C:\GIS\QGIS\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%QGIS_ROOT%\apps\qgis\python
set PYTHONPATH=%PYTHONPATH%;%QGIS_ROOT%\apps\Python37\lib\site-packages
set PYTHONHOME=%QGIS_ROOT%\apps\Python37
set QT_PLUGIN_PATH=%QGIS_ROOT%\apps\qgis\qtplugins;%QGIS_ROOT%\apps\qt5\plugins
set PATH=C:\Program Files\Git\bin;%PATH%
cmd.exe
for Ubuntu users, i tried this and it didn't work out:
pb_tool compile
also tied to install python-qt5 and Ubuntu 20.04 couldn't find it, then used
sudo apt install pyqt5-dev-tool
then pb_tool compile and it worked.

Can't install pygame_sdl2

I'm creating a tower defense game using python and pygame. I would like to add this one on the Google Play Store, but I need to create an apk file.
I'm following a tutorial on GitHub:
https://github.com/renpytom/rapt-pygame-example.
I follow all the instructions but can't install pygame_sdl2.
I use the command prompt, and use $ python setup.py install in the appropriate directory.
But it gave me this error :
C:\Users\gomes\Downloads\pygame_sdl2-master>python setup.py install
Traceback (most recent call last):
File "setup.py", line 59, in <module>
parse_cflags([ "sh", "-c", "sdl2-config --cflags" ])
File "C:\Users\gomes\Downloads\pygame_sdl2-master\setuplib.py", line 93, in parse_cflags
output = subprocess.check_output(command, universal_newlines=True)
File "C:\Python27\lib\subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] Le fichier spÚcifiÚ est introuvable
I tried to reinstall pygame_sdl2-master, but gave me the same result.
You need the appropriate Windows dependencies and cython. I did some researching and testing and found this solution:
Install cython, type this in a terminal:
$ pip install cython
Go to your pygame_sdl2 directory and download the Windows dependencies by typing:
$ git clone https://github.com/renpy/pygame_sdl2_windeps
If it's not in the pygame_sdl2 directory, just move pygame_sdl2_windeps there manually.
Start building the library:
$ python setup.py install
I directly download pygame_sdl2_windeps on github. I have copied this one one the pygame_sdl2 directory and use the "python setup.py install" command in the command prompt, and IT WORKS !!!
C:\PGS4A\pygame_sdl2>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame_sdl2
>>>
Thank you for your help !!!

Anaconda Python and PyDev (in Aptana Studio)

I have just updated my installation of Python 3.4 using Anaconda.
I am now unable to open a PyDev console in Aptana Studio using this version of Python, although I can use a different version of Python.
The error message I get is this:
Error initializing console.
Unexpected error connecting to console.
Failed to recive suitable Hello response from pydevconsole. Last msg received: Console already exited with value: 1 while waiting for an answer.
Error stream: C:\Users\z5044992\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\utils\traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
warn("IPython.utils.traitlets has moved to a top-level traitlets package.")
Error starting server with host: 127.0.0.1, port: 52021, client_port: 52022
Traceback (most recent call last):
File "C:\Users\z5044992\AppData\Roaming\Appcelerator\Aptana Studio\plugins\org.python.pydev_3.0.0.1388187472\pysrc\pydevconsole.py", line 222, in <module>
StartServer(pydev_localhost.get_localhost(), int(port), int(client_port))
File "C:\Users\z5044992\AppData\Roaming\Appcelerator\Aptana Studio\plugins\org.python.pydev_3.0.0.1388187472\pysrc\pydevconsole.py", line 191, in StartServer
interpreter = InterpreterInterface(host, client_port, server)
File "C:\Users\z5044992\AppData\Roaming\Appcelerator\Aptana Studio\plugins\org.python.pydev_3.0.0.1388187472\pysrc\pydev_ipython_console.py", line 30, in __init__
self.interpreter = PyDevFrontEnd(pydev_host=host, pydev_client_port=client_port)
File "C:\Users\z5044992\AppData\Roaming\Appcelerator\Aptana Studio\plugins\org.python.pydev_3.0.0.1388187472\pysrc\pydev_ipython_console_011.py", line 299, in __init__
self.ipython = PyDevTerminalInteractiveShell.instance()
File "C:\Users\z5044992\AppData\Local\Continuum\Anaconda3\lib\site-packages\traitlets\config\configurable.py", line 412, in instance
inst = cls(*args, **kwargs)
File "C:\Users\z5044992\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\terminal\interactiveshell.py", line 396, in __init__
super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
File "C:\Users\z5044992\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 495, in __init__
self.init_completer()
File "C:\Users\z5044992\AppData\Roaming\Appcelerator\Aptana Studio\plugins\org.python.pydev_3.0.0.1388187472\pysrc\pydev_ipython_console_011.py", line 220, in init_completer
self.Completer = self._new_completer_200()
File "C:\Users\z5044992\AppData\Roaming\Appcelerator\Aptana Studio\plugins\org.python.pydev_3.0.0.1388187472\pysrc\pydev_ipython_console_011.py", line 192, in _new_completer_200
use_readline=self.has_readline,
AttributeError: 'PyDevTerminalInteractiveShell' object has no attribute 'has_readline'
I have been following other threads and getting contradictory information about 32 and 64 bit compatibility. I am running 64-bit Win7. I now have both 64 bit and 32 bit versions of Java installed. Aptana only exists as 32 bit for Windows, and I think it uses the 32 bitJava, as Aptana would not initialise when I only had 64 bit Java installed. I have tried both 32-bit and 64-bit versions of Anaconda, with the same result.
I have tried updating ipython.
I have also tried changing the proxy settings to manual and selecting 127.0.0.1 and local host.
I have run out of ideas!
Uninstall Aptana.
Install PyCharm.
Simples.

Python, install Pytables: ValueError: [u'path']

I use command 'pip install tables' in powershell (Windows) to install Pytables. Yet I receive the ValueError: [u'path'].
In red is written 'Command "python setup.py egg_info" failed with error code 1'.
I have miniconda installed.
EDIT: the full red error message is the following:
'Command "python setup.py egg_info" failed with error code 1 in c:\users\evert\appdata\local\temp\pip-build-9wkucl\tables
\'
Between my pip install command and the red error message is written the following:
Collecting tables
Using cached tables-3.2.2.tar.gz
Complete output from command python setup.py egg_info:
* Using Python 2.7.11 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)]
* USE_PKGCONFIG: False
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\evert\appdata\local\temp\pip-build-9wkucl\tables\setup.py", line 553, in <module>
libraries=(package.library_name,))
File "c:\users\evert\miniconda2\lib\distutils\ccompiler.py", line 758, in has_function
objects = self.compile([fname], include_dirs=include_dirs)
File "c:\users\evert\miniconda2\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "c:\users\evert\miniconda2\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "c:\users\evert\miniconda2\lib\site-packages\setuptools-20.3-py2.7.egg\setuptools\msvc9_support.py", line 52,
in query_vcvarsall
File "c:\users\evert\miniconda2\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
Which part is missing? Which steps should I execute before running 'pip install tables'?
Thank you for your help.
This is a problem with not being able to correctly setup certain environment variables required for the setup using vcvarsall.bat. You can download a binary of pytables here instead and do pip install tables-3.2.2-*.whl. Be sure to download the binary matching your version and system architecture.

Categories

Resources