Is there a JMESPath Terminal for windows 10? - python

I have installed python 3.5.2 on my windows 10 machine. I also installed JMESPath Terminal by using following command on windows command line:
pip install jmespath-terminal
Everything went smooth and it was successfully installed.
But when I type following:
jpterm
It says that 'jpterm' is not recognized.
Am I missing something or that above pip command only works on non-windows machines only?

TL;DR: this is currently (dec 2017) simply not supported on Windows.
The install is broken. You can get jpterm.py from the project's GitHub page here and pop it into your \pythonXX\Scripts\ folder.
Then you'll get this:
Traceback (most recent call last):
File "C:\Python36\Scripts\jpterm.py", line 239, in <module>
sys.exit(main())
File "C:\Python36\Scripts\jpterm.py", line 228, in main
screen = urwid.raw_display.Screen()
File "C:\Python36\lib\site-packages\Traceback (most recent call last):
File "C:\Python36\Scripts\jpterm.py", line 239, in <module>
sys.exit(main())
File "C:\Python36\Scripts\jpterm.py", line 228, in main
screen = urwid.raw_display.Screen()
File "C:\Python36\lib\site-packages\urwid\raw_display.py", line 85, in __init__
fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
NameError: name 'fcntl' is not defined\raw_display.py", line 85, in __init__
fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
**NameError: name 'fcntl' is not defined**
...and looking it up in the urwid project issues (the thing that draws "windows" in the terminal), you'll get this:
https://github.com/urwid/urwid/issues/152
which basically says 'urwid doesn't support Windows'.

Related

Pyinstaller can't find package importlib_metadata

I created a new poetry project.
main.py:
import importlib_metadata
PACKAGE_NAME = 'try_pyinstaller'
def get_version():
version = importlib_metadata.version(PACKAGE_NAME)
return version
def main():
version = get_version()
print(version)
if __name__ == "__main__":
main()
when I run pyinstaller with:
pyinstaller --onefile --name main try_pyinstaller\main.py --clean
i get the error:
C:\Users\micha\voltfang_software\tests\python\try_pyinstaller\dist>main.exe
Traceback (most recent call last):
File "importlib_metadata\__init__.py", line 381, in from_name
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "try_pyinstaller\main.py", line 14, in <module>
File "try_pyinstaller\main.py", line 10, in main
File "try_pyinstaller\main.py", line 6, in get_version
File "importlib_metadata\__init__.py", line 832, in version
File "importlib_metadata\__init__.py", line 805, in distribution
File "importlib_metadata\__init__.py", line 383, in from_name
importlib_metadata.PackageNotFoundError: No package metadata was found for try_pyinstaller
[2576] Failed to execute script 'main' due to unhandled exception!
The wierd thing is when I just change variable in version = importlib_metadata.version(PACKAGE_NAME) to version = importlib_metadata.version('try_pyinstaller') it works totally fine. Same environment, nothing else changed. Just put the hardcoded string in.
is this a bug or am I doing something wrong?
The answer to this question can be found here:
https://github.com/pyinstaller/pyinstaller/issues/7399
In short:
If you use importlib_metadata.version('try_pyinstaller'), PyInstaller's bytecode scanning can infer that metadata for try_pyinstaller needs to be collected. If you use a variant with non-literal argument, importlib_metadata.version(PACKAGE_NAME), it cannot do that, and you need to explicitly instruct it to collect metadata via --copy-metadata try_pyinstaller.

Install Ansible Windows Machine

I have tried installing ansible through pip install ansible but whenever i get the following error trying to use it:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\ruan.greyling\AppData\Local\Programs\Python\Python311\Scripts\ansible.exe\__main__.py", line 4, in <module>
File "C:\Users\ruan.greyling\AppData\Local\Programs\Python\Python311\Lib\site-packages\ansible\cli\__init__.py", line 42, in <module>
check_blocking_io()
File "C:\Users\ruan.greyling\AppData\Local\Programs\Python\Python311\Lib\site-packages\ansible\cli\__init__.py", line 34, in check_blocking_io
if not os.get_blocking(fd):
^^^^^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'get_blocking'
I have python and pip installed on the machine.
It looks like this may be a version compatibility issue with Python 3.11. I recommend upgrading to the latest version of Python and then running the command again.
This is why you are getting this error.
Windows without WSL is not natively supported as a control node (more in the documentation)
If you want to run the Control node on Windows use WSL
Good practice code repository and sync to your Linux Control node from Windows machine.

runsnake fails in ubuntu with error in squaremap

When I start runsnake with
$ runsnake test.profile
the window opens, but with no graphics and no source code (only the list of calls, etc. is present). On the console, I see the following error message:
11:18:17: Debug: Adding duplicate image handler for 'PNG file'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/wx/core.py", line 3282, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
File "/usr/lib/python3/dist-packages/runsnakerun/runsnake.py", line 701, in load
self.SetModel(self.loader)
File "/usr/lib/python3/dist-packages/runsnakerun/runsnake.py", line 738, in SetModel
self.squareMap.SetModel(tree, self.adapter)
File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 221, in SetModel
self.UpdateDrawing()
File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 247, in UpdateDrawing
self.Draw(dc)
File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 257, in Draw
font = self.FontForLabels(dc)
File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 267, in FontForLabels
font.SetPointSize(scale * font.GetPointSize())
TypeError: Font.SetPointSize(): argument 1 has unexpected type 'float'
I installed runsnake using
sudo apt-get install runsnake
The versions of the dependencies are, according to pip list:
RunSnakeRun 2.0.5
SquareMap 1.0.5
wxPython 4.0.7
My system is
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
A quick hack is to change the code that you run by modifying the code:
$ sudo $EDITOR /usr/lib/python3/dist-packages/squaremap/squaremap.py
Go to line 267
Then replace the line with:
font.SetPointSize(int(scale * font.GetPointSize()))
or hardcode someting:
font.SetPointSize(18)

Python Installation in local directory gives "ModuleNotFoundError": 'msvcrt'

I'm using my company's VM which already has Python 2.7 (comes with the OS) and Python 3.6.13 (Installed by the company)
Recently, there is a need to upgrade an application to latest version of Python ie: 3.10.2
So, I installed Python 3.10.2 in a local directory inside my $HOME. I referred to this link for the installation link.
While 2.7 & 3.6 are already there in the system.
Now, when I try to create a VENV with this python version (3.10.2), I see this error:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 69, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/venv/__init__.py", line 10, in <module>
import subprocess
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 74, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I found some solutions like this one: link but I cannot figure out how it will translate in my case since my installation directory is not /usr/local/... It is $HOME/path/to/dir
Python on Linux does not have the msvcrt module at all. It's strictly Windows only. You seem to have miscompiled your Python somehow, since it also doesn't have the _posixsubprocess module (and msvcrt is used for Windows detection in subprocess.py).
May I recommend using pyenv or asdf for custom Python versions? They're less likely to miscompile Python.

Python ide thonny installation error in ubuntu

I am facing the below issue while installing thonny ide for python.
Traceback (most recent call last):
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/workbench.py", line 287, in _init_runner runner.start()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 67, instart self.reset_backend()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 427, in reset_backend self._proxy = backend_class(configuraration_option)
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 596, in __init__ self._start_new_process()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 762, in _start_new_process my_env["JEDI_LOCATION"] = self_prepare_jedi()
File "/home/shrivatsa/.local/lib/python3.5/site-packages/thonny/running.py", line 703, in _prepare_jedi import jedi ImportError: No module named 'jedi'
The application launches but no run button and dedug button is active.
As the error message shows you are missing the module named "jedi".
Try to install it before installing the IDE:
pip install jedi
According to Thonny blog, this IDE uses Jedi (autocompletion/static analysis library). So make sure it also installed (via pip, for example).

Categories