I'm trying to read pulse with the 'countio' library from CircuitPython. When I'm importing the library, it says:
Traceback (most recent call last):
File "fanfan.py", line 2, in
import countio
ModuleNotFoundError: No module named 'countio'
Here is the codes I used:
import board
import countio
# Count rising edges only.
pin_counter = countio.Counter(board.D1, edge=countio.Edge.RISE)
# Reset the count after 100 counts.
while True:
if pin_counter.count >= 100:
pin_counter.reset()
print(pin_counter.count)
I tried
pip3 install countio
but it's not working.
Is there any way to install the countio library on Raspberry pi 4B?
Of course it fails. Because it simply does NOT exist: click me
A very simpl look up on the homepage of CircuitPython revails the actual libraries:
So, to answer your question: No, there is no way to install countio library on any platform, because it does not exist.
Related
I am trying to learn how to use pymem in Python.
I have tried to make two different programs according to two tutorials I have seen but I always get the same error when I try to run the code.
I have this:
from pymem import Pymem
pm = pymem("ac_client.exe")
health = pm.read_int(0x007B43F4)
print ("Health: ", health)
But when I try to run the code I get the following error:
Traceback (most recent call last):
File "c:\Users\N\Desktop\PYTHON\pymem\pymem2.py", line 1, in <module>
from pymem import Pymem
File "c:\Users\N\Desktop\PYTHON\pymem\pymem.py", line 4, in <module>
from pymem.process import *
ModuleNotFoundError: No module named 'pymem.process'; 'pymem' is not a package
I have pymem installed in it's latest version from Visual Studio Code. And in the videos I've seen (one is from a few months ago) they have the same code as me.
You have a file named pymem.py that's mentioned in the exception message (specifically c:\Users\N\Desktop\PYTHON\pymem\pymem.py). This locally written pymem module is shadowing the pymem package you've installed elsewhere (python\python310\lib\site-packages according to one of your comments, though that path is not complete).
You need to rename your pymem.py file to something else if you want to be able to use the package.
I think you don't have it installed, try going into cmd, Terminal or whatever and type pip install pymem.
pip should install the package for you and you should be good.
I am running the following blink program on my raspberry pi pico. I am using circuit python.
from machine import Pin
import time
led = Pin(13, Pin.OUT)
while True:
led(1)
time.sleep(1)
led(0)
time.sleep(1)
When I run it though it gives this error:
Traceback (most recent call last):
File "code.py", line 1, in <module>
ImportError: no module named 'machine'
I have tried to find if I need to download a library file or any thing about the machine module, but I have found nothing. If you know why it can't find the machine module that would be greatly appreciated.
Your code is for micropython. Circuitpython is different. See here https://learn.adafruit.com/circuitpython-essentials/circuitpython-digital-in-out
from digitalio import DigitalInOut, Direction, Pull
led = DigitalInOut(board.LED)
I was having same issue and a search found this thread.
I changed the Interpreter setting in Thonny (under options) from Local Python 3, to MicroPython (Raspberry Pi Pico)
I think you are using the incorrect uf2 file as the official (stable) version is not out as of writing this.
In order to check this, type the following in MircoPython's command line:
import sys
sys.implementation
(name='micropython', version=(1, 19, 1), _machine='Raspberry Pi Pico with RP2040', _mpy=4102)
If the response shows "Pico" and not "Pico W" then copy the latest version from here and copy it onto your Pico W (in USB mode)
I am having a lot of trouble with getting the Google Cloud Natural Language API running. I am trying to run a Python program in Linux on a Google VM. I am also unsure of how to run a full Traceback of the error. The following code is not working:
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types.
On Python 2 I get the error:
Traceback (most recent call last):
File "natlangex.py", line 3, in <module>
from google.cloud.language import enums
ImportError: cannot import name enums
I tried upgrading to Python 3 and when I run Python 3 I get the error:
And I updated to Python 3. One thing that is confusing is that when I run Python 3 the error is a bit different:
Traceback (most recent call last):
File "natlangex.py", line 2, in <module>
from google.cloud import language
ImportError: No module named 'google'
Here are the other things I have tried:
I installed the SDK.
I set export GOOGLE_APPLICATION_CREDENTIALS="apikey.json".
I tried !pip install google-cloud-language
I upgraded pip pip install --upgrade setuptools pip.
I am very lost! Thank you in advance.
It seems that you are using wrong syntax because of the library update, you may refer now to the new one, following [1] and more specifically [2].
It seems that the official Natural Language documentation of Google Cloud is not updated yet [3], but at the end of this documentation you have links to the Python Client Library [1][2] where it explains the changes.
Your imports should be:
from google.cloud import language_v1
from google.cloud.language_v1 import enums
from google.cloud.language_v1 import types
[1] https://googleapis.dev/python/language/latest/api.html
[2] https://googleapis.dev/python/language/latest/gapic/v1/api.html
[3] https://cloud.google.com/natural-language/docs/reference/libraries#client-libraries-usage-python
I am trying to send data to the Azure Blob Storage and my first step was to just check the connection by using the sample code I found on the tutorial website:
from azure.storage.blob import BlockBlobService
blob_service = BlockBlobService(account_name, account_key)
blob_service.create_container(
'mycontainername',
public_access=PublicAccess.Blob
)
blob_service.create_blob_from_bytes(
'mycontainername',
'myblobname',
b'<center><h1>Hello World!</h1></center>',
content_settings=ContentSettings('text/html')
)
print(blob_service.make_blob_url('mycontainername', 'myblobname'))
Of course entered the account name and the account key. But I get this error, which I also get when using my own python script so this is a big problem for me:
Traceback (most recent call last):
File "azuretest.py", line 1, in <module>
from azure.storage.blob import BlockBlobService
ImportError: No module named 'azure'
I am a beginner in this topic and I am very lost. Can anyone tell me what to do? Thanks
Installing just the azure-storage library should be sufficient in stead of installing the entire SDK.
pip install azure-storage
Edit
I see you have already done this. The package might not be in your python path. You could try adding
import sys
sys.path.append('/usr/local/lib/python3.6/dist-packages')
at the top of your script (but I am not 100% sure that it will be there on your syste, it is on ubuntu)
or append it to your PYTHONPATH environment variable.
I use mac ports to install python and many other modules like pygame, numpy, networkx. Codes work well on spyder and IDLE.
But when using sublimeREPL to run codes in python. It says "no module named pygame", like the follows(Sorry I cant post image for short of reputations)
Traceback (most recent call last):
File "12.py", line 2, in <module>
import pygame
ImportError: No module named pygame