nrfutil changes python version mid-script - python

I'm using nrfutil in a shell script. It's failing with this error:
Traceback (most recent call last):
File "/usr/local/bin/nrfutil", line 6, in <module>
from nordicsemi.__main__ import cli
File "/Library/Python/2.7/site-packages/nordicsemi/__main__.py", line 57, in <module>
from nordicsemi.zigbee.prod_config import ProductionConfig, ProductionConfigWrongException, ProductionConfigTooLargeException
File "/Library/Python/2.7/site-packages/nordicsemi/zigbee/prod_config.py", line 41, in <module>
import yaml
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/yaml/__init__.py", line 374
class YAMLObject(metaclass=YAMLObjectMetaclass):
It's starting in python 2.7, then it looks like its running "import yaml" from a 3.6 library.
Why would it do this? How do I prevent it?
Thanks

I had an old version of nrfutil. I upgraded, all is good

Related

Idle3 editor fail to open in Fedora 36

I am currently unable to open Idle3 editor. I am running Linux Fedora 36, when idle3 command is issued I get this:
Traceback (most recent call last):
File "/usr/bin/idle3", line 3, in <module> from idlelib.pyshell import main
File "/usr/lib64/python3.10/idlelib/pyshell.py", line 53, in <module> from idlelib import debugger
File "/usr/lib64/python3.10/idlelib/debugger.py", line 7, in <module> from idlelib import macosx
File "/usr/lib64/python3.10/idlelib/macosx.py", line 7, in <module> from test.support import requires, ResourceDenied
ModuleNotFoundError: No module named 'test'
I don't know how to solve it.
Fortunatelly the trouble with Idle3 was solved in the recent update of Fedora 36, I think the missing file was inserted.

import libusb "This OS is not supported yet!"

I have been trying to code the display on my Ableton push 2 with python using this guide: github.com/ffont/push2-python#using-the-simulator, but I ran into a problem with pyusb and i was missing libusb. pip3 kept saying I already had it installed but I still kept getting errors when trying to use Libusb. So i tried using homebrew and it installed it but I still keep getting errors when using libusb.
this is what my terminal looks like when trying to import:
>>> import libusb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/__init__.py", line 7, in <module>
from ._libusb import * ; del _libusb # noqa
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/_libusb.py", line 29, in <module>
from ._platform import CFUNC
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/_platform/__init__.py", line 33, in <module>
from ._osx import DLL_PATH, DLL, dlclose, CFUNC
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/libusb/_platform/_osx/__init__.py", line 14, in <module>
raise NotImplementedError("This OS is not supported yet!")
NotImplementedError: This OS is not supported yet!

Python: import autobahn_autoreconnect causes RuntimeError

I want to use the module autobahn-autoreconnect and it works fine locally with PyCharm. I just install the module with PyCharm and exchange the old ApplicationRunner line with the new one:
# from autobahn.asyncio.wamp import ApplicationRunner
from autobahn_autoreconnect import ApplicationRunner
But when I install it on an Ubuntu server with pip3 install autobahn-autoreconnect and then use just import autobahn_autoreconnect I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/autobahn_autoreconnect/__init__.py", line 31, in <module>
from autobahn.wamp import protocol
File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 272, in <module>
class ApplicationSession(BaseSession):
File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 277, in ApplicationSession
log = txaio.make_logger()
File "/usr/local/lib/python3.5/dist-packages/txaio/_unframework.py", line 43, in _throw_usage_error
"To use txaio, you must first select a framework "
RuntimeError: To use txaio, you must first select a framework with .use_twisted() or .use_asyncio()
What am I doing wrong?
The following solution worked for me.
First:
import txaio
txaio.use_asyncio()
Second:
from autobahn_autoreconnect import ApplicationRunner

Google cloud sdk not working when python points python3

I am currently trying to install google cloud sdk on my macbook. I am using scikit-learn and anaconda for machine learning so on my laptop python points to python3.5. However google cloud sdk requires python 2.7 for installation, and that's why I am facing the problem of not be able to install it.
when I ran the install.sh file the error occurred and I have no clue how to deal with it:
Adam | ~ $ git/google-cloud-sdk/install.sh
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 364, in __getattr__
return cls._member_map_[name]
KeyError: '_convert'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/AdamLiu/git/google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
import bootstrapping
File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 9, in <module>
import setup
File "/Users/AdamLiu/Git/google-cloud-sdk/bin/bootstrapping/setup.py", line 34, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/AdamLiu/Git/google-cloud-sdk/lib/googlecloudsdk/core/util/platforms.py", line 18, in <module>
import platform
File "/Users/AdamLiu/anaconda/lib/python3.5/platform.py", line 117, in <module>
import sys, os, re, subprocess
File "/Users/AdamLiu/anaconda/lib/python3.5/subprocess.py", line 364, in <module>
import signal
File "/Users/AdamLiu/anaconda/lib/python3.5/signal.py", line 8, in <module>
_IntEnum._convert(
File "/Users/AdamLiu/Git/google-cloud-sdk/lib/third_party/enum/__init__.py", line 366, in __getattr__
raise AttributeError(name)
AttributeError: _convert
Super thanks in advance!
Set the CLOUDSDK_PYTHON environment variable to the location of your Python 2.x executable before running install.sh.
Or make sure that you have python2 in your path so that which python2 can find it.

Error importing sdl2 in python3

I have a file test.py which contains only the line "import sdl2". I am running Ubuntu and have installed libsdl2 from the official repos and installed pysdl2 from pip3. I get this error:
Traceback (most recent call last):
File "./test.py", line 2, in <module>
import sdl2
File "/usr/local/lib/python3.3/dist-packages/sdl2/__init__.py", line 11, in <module>
from .events import *
File "/usr/local/lib/python3.3/dist-packages/sdl2/events.py", line 5, in <module>
from .keyboard import SDL_Keysym
File "/usr/local/lib/python3.3/dist-packages/sdl2/keyboard.py", line 7, in <module>
from .video import SDL_Window
File "/usr/local/lib/python3.3/dist-packages/sdl2/video.py", line 256, in <module>
SDL_GL_ResetAttributes = _bind("SDL_GL_ResetAttributes")
File "/usr/local/lib/python3.3/dist-packages/sdl2/dll.py", line 84, in bind_function
(funcname, self._dll))
ValueError: could not find function 'SDL_GL_ResetAttributes' in <CDLL 'libSDL2-2.0.so.0', handle 1088720 at 7fdce18f5910>
My only thought is that possibly there's some version mismatch in packages? I couldn't find anything referencing this bug after a quick googling.
This is a bug in pysdl2, which indicates that your SDL2 library version is not the latest one. (2.0.3). It has been fixed in a recent commit: https://bitbucket.org/marcusva/py-sdl2/commits/03870c58615b115abf14b11056bbcd41652873c5

Categories

Resources