I've been working on Raspberry-Pi3 and SHARP IR-sensor(2Y0A02 F 8Z),i've imported all the dependencies but still i get the error as :
Import Error: No Module named Adafruit_GPIO.SPI
I've installed Adafruit_GPIO :
pip3 install Adafruit_MCP3008
import time
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008
CLK=18
MISO=23
MOSI=24
CS=25
mcp=Adafruit_MCP3008.MCP3008(clk=CLK,cs=CS,miso=MISO,mosi=MOSI)
while True:
v=(mcp.read_adc(0)/1023.0)*3.3
dist = 16.2537 * v**4 - 129.893 * v**3 + 382.268 * v**2 - 512.611 * v + 301.439
print("Distance {:.2f}".format(dist))
time.sleep(2)
This is the Error generated:
Traceback (most recent call last):
File "test1.py", line 2, in <module>
import Adafruit_GPIO.SPI as SPI
ModuleNotFoundError: No module named 'Adafruit_GPIO'
Related
I am facing some import error....But cv2 was succesfully installed in my mac....Pls provide some solution
This is my code
import cv2
img=cv2.imread("galaxy.jpg",1)
print(img)
This is output
akshitdudeja#Akshits-MacBook-Air Sec-17 % python3 script.py
Traceback (most recent call last):
File "/Users/akshitdudeja/VS Code/main_folder/UDEMY/Sec-17/script.py", line 1, in <module>
import cv2
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cv2/__init__.py", line 180, in <module>
bootstrap()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cv2/__init__.py", line 152, in bootstrap
native_module = importlib.import_module("cv2")
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cv2/cv2.cpython-310-darwin.so, 0x0002): tried:
'/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cv2/cv2.cpython-310-darwin.so' (mach-o file, but is an incompatibl
e architecture (have 'arm64', need 'x86_64')), '/usr/lib/cv2.cpython-310-darwin.so' (no such file)
I have done the import of Discord-Components via pip install --upgrade discord-componentsin Shell
And then I imported into the code (line of import from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType)
but I cannot import InteractionType???
File "main.py", line 19, in <module>
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType
ImportError: cannot import name 'InteractionType' from 'discord_components' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/__init__.py)
InteractionType is removed in 2.0.0 as stated in the latest (gitbook) docs.
Docs link: https://devkiki7000.gitbook.io/discord-components/change-log/2.0.0#breaking-changes
Use integers to replace them.
ChannelMessageWithSource = 4
DeferredChannelMessageWithSource = 5
DeferredUpdateMessage = 6
I'm trying things out on windows vs linux where I have this working in 3.8 and 3.9.5, but not on windows using anaconda
import sys
sys.path.append("../")
from datetime import time
import pandas as pd
import pandas_market_calendars as mcal
error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\pandas_market_calendars\__init__.py", line 19, in <module>
from .calendar_registry import get_calendar, get_calendar_names
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\pandas_market_calendars\calendar_registry.py", line 21, in <module>
from .exchange_calendars_mirror import *
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\pandas_market_calendars\exchange_calendars_mirror.py", line 9, in <module>
import exchange_calendars
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\exchange_calendars\__init__.py", line 16, in <module>
from .calendar_utils import (
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\exchange_calendars\calendar_utils.py", line 3, in <module>
from .always_open import AlwaysOpenCalendar
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\exchange_calendars\always_open.py", line 5, in <module>
from .exchange_calendar import ExchangeCalendar
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\exchange_calendars\exchange_calendar.py", line 27, in <module>
from .calendar_helpers import (
File "C:\Users\User\Anaconda3\envs\py39\lib\site-packages\exchange_calendars\calendar_helpers.py", line 6, in <module>
NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType
'
Posted a github bug
indeed something changed and the culprit is pandas
https://github.com/rsheftel/pandas_market_calendars/issues/137
to solve, install pandas==1.2.5 and it will work
The error is with the underlying exchange_calendars package (https://github.com/gerrymanoim/exchange_calendars). It appears that error has been fixed in that package. If you update the exchange_calendars package everything will work fine. Nothing to do in this package.
Fix: gerrymanoim/exchange_calendars#41
I am trying to test the sphinx extension TODO from https://sphinx.readthedocs.io/en/master/development/tutorials/todo.html#writing-the-extension
However, this import "from docutils.parsers.rst import SphinxDirective" does not work, giving "Extension error:
Could not import extension todo (exception: No module named SphinxDirective)
"
I tried python2 and python3 , and readthedocs environment.
the code is here, https://www.sphinx-doc.org/en/master/development/tutorials/todo.html#writing-the-extension
ReadTheDocs gives this message:
Running Sphinx v1.8.5
loading translations [en]... done
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 472, in load_extension
mod = __import__(extname, None, None, ['setup'])
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/checkouts/latest/docs/todo.py", line 6, in <module>
from docutils.parsers.rst import SphinxDirective
ImportError: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 228, in __init__
self.setup_extension(extension)
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 449, in setup_extension
self.registry.load_extension(self, extname)
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 475, in load_extension
raise ExtensionError(__('Could not import extension %s') % extname, err)
sphinx.errors.ExtensionError: Could not import extension todo (exception: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py))
Extension error:
Could not import extension todo (exception: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py))
Well,
one has to use proper files from the tutorial, https://www.sphinx-doc.org/en/master/development/tutorials/todo.html , together with all installed packages.
This is ensured on the ReadTheDocs portal, where the extension buildup works well.
PS: Files and links are https://github.com/miroi/demo-sphinx-extensions-for-DIRAC
I'm new to caffe.When I try the caffe,the problem occurs.Anyone can help?Thanks in advance!
>>> import google.protobuf
>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/llzxo/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/llzxo/caffe/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/llzxo/caffe/python/caffe/io.py", line 8, in <module>
from caffe.proto import caffe_pb2
File "/home/llzxo/caffe/python/caffe/proto/caffe_pb2.py", line 10, in <module>
from google.protobuf import symbol_database as _symbol_database
ImportError: cannot import name symbol_database
It may be due to version incompatibility of your installed protobuf. Try to upgrade protobuf by:
sudo pip install --upgrade protobuf