Web streaming using Raspberry pi 3 model b and picam - python

I am trying to stream video in web using Raspi cam. I am using a code from internet but it has an error and it shows this,
Traceback (most recent call last):
File "picam.py", line 8, in <module>
import socketserver
ImportError: No module named socketserver
I don't know what to do. Help me please? THANKYOUUUU!
The code I'm using is in http://picamera.readthedocs.io/en/latest/recipes2.html#web-streaming
(4.10 WEB STREAMING)

You are most probably using Python2 which has SocketServer.
I'll recommend that you use Python3 which has socketserver.
Reference -> No Module Named ServerSocket

Related

Raspberry Pi Pico ImportError: no module named 'machine'

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)

Returning audio using os.system Python FIXED

I would like to return audio using os.system because, in PyCharm, it returns the error:
"Traceback (most recent call last):
File "/Users/Milo/Desktop/python/Joe.py", line 5, in
import pyttsx
File "/private/var/folders/z_/wpk6crsn2slfh_1y5hytwsvr0000gp/T/Joe.py/venv/lib/python3.6/site-packages/pyttsx/init.py", line 18, in
from engine import Engine
ModuleNotFoundError: No module named 'engine'".
For example:
import pyttsx
engine = pyttsx.init()
engine.say('This is a test')
engine.runAndWait()
'''Somehow play sound/voice'''
Am I using the wrong pyttsx module? Did I install it wrong? I am using python 3.6.4 and am using Mac OSX. I highly prefer that if I need a new module, it works with NSSpeechSynthesizer. Should I just run it via terminal? However, I would like to use it with PyCharm. Let me know if there if there is any info you need to know the I did not disclose.
Thanks.

Python jsonrpclib not working after upgrade to Python 3.5.2

I previously had Python 2.7 installed and was making calls like this:
api = jsonrpclib.Server('my host')
api.someFunctionCall()
I then upgraded to Python 3.5.2 and now when I run the code above, I'm receiving this message:
Traceback (most recent call last):
File "C:\login\login.py", line 1, in <module>
import jsonrpclib
File "C:\Python3.5.2\lib\site-packages\jsonrpclib\__init__.py", line 5, in <module>
from jsonrpclib.jsonrpc import Server, MultiCall, Fault
ImportError: No module named 'xmlrpclib'
I checked my installation and I do indeed have the xmlrpc lib:
c:\Python3.5.2\Lib\xmlrpc
What am I doing wrong?
Python 3.x has relocated the xmlrpclib module. Per the Python 2.7 xmlrpclib documentation:
"The xmlrpclib module has been renamed to xmlrpc.client in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3."
It looks like the author of jsonrpclib has an open issue for Python 3 support, but hasn't responded or taken pull requests in a year. You may want to give the jsonrpclib-pelix fork a look for Python 3 support.

Error while trying to import socket?

I've recently installed python, ipython and pip, with pip I've installed the socket library, and plenty others, now I can't import socket while running python program through cmd but I can do it using ipython,
When I run ipython and I import socket everything works fine,
now I wrote a simple script, called "tcp.py" and all it contains is nothing but the following line
Import Socket
Traceback (most recent call last):
File "C:\dir\desktop\tcp.py", line 1, in <module>
import socket
File "C:\dir\desktop\socket.py", line 1, in <module>
socket
NameError: name 'socket' is not defined
Any idea how to solve this?
You've made two mistakes: the first is to have your own file named "socket.py". This shadows the stdlib module, so when you import socket, it finds your file instead of the module in the stdlib. The second mistake is that your "socket.py" file has the word socket in it. This is what is actually causing your error: the word socket is undefined.
Delete your "socket.py" file, and any *.pyc files lying around, and the problem will be fixed.
If you read the traceback (error report) closely, you can see what's happened.

python from mac ports, sublimeREPL dosnt run

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

Categories