Unable to install picamera2 on Rasbperry Pi - python

I'm trying to run a python script in my Rasbperry pi that imports the package picamera2. Specifically using from picamera2 import Picamera2,Preview
However, I'm getting this error:
ImportError: No module named 'picamera2'
Struggling to get it installed. Why can't this package be found?
I've tried to install the package by doing an update and installing the package (as indicated in https://github.com/raspberrypi/picamera2)
sudo apt update
sudo apt full-upgrade
sudo apt install -y python3-picamera2
But running the last line returns the error: Unable to locate package python3-picamera2
I've also tried pip install picamera2 but that returns No matching distribution found for picamera2
Info:
Rasbperry pi 3 Model B
OS: Raspbian GNU/Linux 9 (stretch)

I had the same error. I resolved running: /usr/bin/python3 ./your_script.py instead of python ./your_script.py.
The problem was that my default python was /home/pi/miniconda3/bin/python but the command sudo apt install -y python3-picamera2 installs the package for /usr/bin/python3. This at least what I understood.

Related

How to solve the Import Error of cv2 module

I know that there are many questions and answers regarding this.
But I couldn't solve it.
I get
ImportError: DLL load failed while importing cv2: The specified module could not be found.
I have
Windows 11,
Python 3.9.12
opencv-python and opencv-contrib-python 4.6.0.66
PyCharm IDE
I tried
installing Visual build tools
OpenCV Python library is an Interface to C++ library, so in order to run the code, you should install the CMake.
$ apt-get update && apt-get install -y cmake build-essential libgtk-3-dev libboost-all-dev
If you are trying to run it in docker, just change the $ to a RUN before install requirements.txt.
I hope this help you. Obs: I'm also using Windows 11 and WSL2. For me, it takes around 10 minutes to complete the apt and pip install, but worked for me.

Package 'python3-venv' has no installation candidate

I'm currently trying to install Flask for testing a simple web page.
Unfortunately i got the following message:
Command 'virtualenv' not found, but can be installed with:
sudo apt install python3-virtualenv
When i do it, i got :
Unable to locate package python3-virtualenv
I check my python version and I'm on Python 3.10.4
Whent i try sudo apt-get update i got:
W: Some index files failed to download. They have been ignored, or old ones used instead.
Whent i try sudo apt-get upgrade i got:
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
And when i try sudo apt-get install python3-venv i got :
E: Package 'python3-venv' has no installation candidate
sudo apt install python3-virtualenv works perfectly fine with me.
Alternatively you can install it using pip
pip3 install virtualenv
After completion you can check for which virtualenv to get the path of the location where it has been installed.
It seems there is an error with your ubuntu, You can use this site and fix it and then install the virtual environment : https://www.tecmint.com/some-index-files-failed-to-download.
Had this problem after upgrading to Ubuntu 20.4 and all my problems stemmed from a very old version of Pip that was solved by this lovely command:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3
More information and some alternatives here: pip3 install not working - No module named 'pip._vendor.pkg_resources'

How to install the pyautogui module on RedHat

I've been using the Python module pyautogui on Windows where it is fairly simple to install and need to install it on a RedHat server for work.
The official documentation gives the following instructions for Linux installation:
pip3 install python3-xlib
sudo apt-get install scrot
sudo apt-get install python3-tk
sudo apt-get install python3-dev
pip3 install pyautogui
Now, two things bother me with this:
1) It assumes using Python 3 but we're using Python 2. Does it imply that the module only exists for Python 3 in Linux? Because I have been using it for Python 2 on Windows.
2) Dependency-wise, it assumes using Debian's package manager APT, certainly these dependencies should be available on a RedHat system with yum.
I first decided to install python-xlib which is the Python 2 version of the first package and it worked.
Secondly I tried:
sudo yum install scrot
Which resulted in the error "No package Scrot available". Finding a dead-end this way, I tried to manually download the sources for Scrot and install it.
I followed the instructions:
$ wget http://linuxbrit.co.uk/downloads/scrot-0.8.tar.gz
$ tar -xvf scrot-0.8.tar.gz
$ cd /scrot-0.8
$ ./configure --prefix=/usr
$ make
$ su -c "make install"
Which only resulted in getting the error
checking whether to enable maintainer-specific portions of Makefiles... no
checking for giblib-config... no
checking for giblib - version >= 1.2.3... no
*** The giblib-config script installed by giblib could not be found
*** If giblib was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the GIBLIB_CONFIG environment variable to the
*** full path to giblib-config.
configure: error: Cannot find giblib: Is giblib-config in the path?
I found some threads addressing the issue and roughly asking to install giblib. However, I failed in doing so. Again, I only found instructions to install it in Debian-like systems and could not find out how to install it on a RedHat system. So now I'm trying to download and install the sources of giblib but this is beginning messy, especially given the fact that I'll have to ask that pyautogui to be installed on our production servers and I don't see myself explaining to my boss such a tremendous and bulky procedure. That would get rejected right away.
So I am now asking for help, a perhaps better or easier way to install the Python pyautogui moduke for Python 2 on a RedHat system. Or maybe even a similar module, I could not find any, as simple and efficient to use, alternative.
If someone could help me on this, that would be really helpful and would save me a lot of work and dead-ends.
I was facing the exact same issue, got into a loop of missing dependencies. Finally, someone helped me out, and it works.
yum install epel-release
yum install wget imlib2
wget http://packages.psychotic.ninja/7/base/x86_64/RPMS/scrot-0.8-12.el7.psychotic.x86_64.rpm
wget http://packages.psychotic.ninja/7/base/x86_64/RPMS/giblib-1.2.4-22.el7.psychotic.x86_64.rpm
rpm -Uvh giblib-1.2.4-22.el7.psychotic.x86_64.rpm
rpm -Uvh scrot-0.8-12.el7.psychotic.x86_64.rpm
And that's it. I was able to use PyAutoGUI after this.
I got scrot installed to Centos7 with following steps:
https://pkgs.org/:
Download & install:
giblib-devel-1.2.4-22.el7.psychotic.x86_64.rpm
giblib-1.2.4-22.el7.psychotic.x86_64.rpm
sudo yum --nogpgcheck localinstall
http://scrot.sourcearchive.com/downloads/0.8-8/:
Download:
scrot_0.8.orig.tar.gz
Install:
tar xvf scrot_0.8.orig.tar.gz
cd scrot-0.8/
./configure
make
sudo make install
I had a problem with Xlib in the install of PyAutoGUI with python 3 and somehow I managed to solve that problem and I want to share that here based on the question title "install the PyAutoGUI on linux RedHat"
error of installing PyAutoGUI with python 3 is something like this
Xlib.error.XauthError: ~/.Xauthority: [Error 2] No such file or directory: '/home/username/.Xauthority'
to install PyAutoGUI without error:
way 1 __
first, install Xlib
sudo yum install libX11
after that install this tow package
pip install PyUserInput
pip install PyAutoGUI
if that did not work for you, install python3-xlib before PyUserInput & PyAutoGUI
pip install python3-xlib
way 2 __
download (xvfb-run) from pkgs.org and install that with following command
rpm -ivh yourfile.rpm
then with help of xvfb-run you can install and even use PyAutoGUI code without error...
xvfb-run pip install PyAutoGUI
way 3 __
install one of this ( python3-xlib || python-xlib )
pip install python3-xlib
and then
export DISPLAY=:0
pip install PyAutoGUI

Python Programming with raspberry Pi...Import mysqldb error

update Error Installation ErrorI am trying to access a database using python.when i am executing my script its giving error, Import Error:-No module named MySQL . I have even tried it to run with lower versions of python but the same error came.I tried to install the MySQL package using the command sudo apt-get install python-mysqldb but it throwing some error.
So i write a answer, so that the question could be marked as "answered".
The problem was losing internet connection. APT need internet connection to download the packages from source.
For someone, who want to install python module MySQLDB in Debian or Ubuntu:
apt-get update
apt-get install python-mysqldb
If you want to install MySQLDB from pip, you need to install all the prerequisites for python-mysqldb first (for virtualenv)
apt-get build-dep python-mysqldb
pip install mysql-python

Having trouble installing PyAudio for Python3 on Mint

I was following the instructions here and I'm having trouble getting the installation to work. Basically, the first part works fine. I downloaded portaudio, followed the instructions, and it all seemed to work.
However, when I triedpython3 setup.py install, I got an error. The error came from the /src/_portaudiomodule.c file, and it said that "The file Python.h could not be found". I don't really understand what's going on because there was no Python.h file when I extracted the PyAudio archive. I don't know where the Python.h file was supposed to come from.
I'm kind of a noob to unix systems so I could have easily made a mistake somewhere. I've been trying to solve this for hours and I've had no luck so far. Thanks in advance for your help!
To install the latest version of pyaudio using conda:
source activate -your environment name-
pip install pyaudio
You may run into the following error when installing from pip:
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
compilation terminated.
error: command 'gcc' failed with exit status 1
That is because you don't have the PortAudio development package installed. Install it with:
sudo apt-get install portaudio19-dev
You don't need to compile pyaudio. To install PyAudio, run:
$ sudo add-apt-repository universe
$ sudo apt-get install python-pyaudio python3-pyaudio
The first command enables Universe Ubuntu repository.
If you want to compile it e.g., to use the latest version from git; install build dependencies:
$ sudo apt-get build-dep python-pyaudio python3-pyaudio
After that, you could install it from sources using pip:
$ python3 -mpip install pyaudio
Or to install the current version from git:
$ pip install -e git+http://people.csail.mit.edu/hubert/git/pyaudio.git#egg=pyaudio
Run pip commands inside a virtualenv or add --user command-line option, to avoid modifying the global python3 installation (leave it to the package manager).
I've tested it on Ubuntu. Let me know if it fails on Mint.
I have found the work arround for mac.
please refer the below steps to install pyaudio on python 3.5
Follow these steps :
export HOMEBREW_NO_ENV_FILTERING=1
xcode-select --install
brew update
brew upgrade
brew install portaudio
pip install pyaudio
I was able to get it install with anaconda, using this package.
Follow install instructions for linux here, then do:
conda install -c bokeh pyaudio=0.2.7
try to install using the the below command
pip install pyaudio
after that install the required Microsoft Visual C++ 14.0
refer the below image for the same.
and restart the system and run the same command again
pip install pyaudio
Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. To install this package, enter:
sudo apt-get install python3-dev

Categories

Resources