What has happened to python-serial? - python

I have had replace an old PI2B, Jessie, Python 2.7, which satisfactorily ran some python code, with PI3B, Buster, Python 3.7, but I now cannot find/load python-serial. 'sudo apt-get install python-serial' installs it but when my python code is run it reports it as missing and 'sudo pip install python-serial' can't install it and comes back with the error below. Has it been replaced/superseded? What can I do to enable 'import serial' to work? Thanks
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python-serial
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/python-serial/"
Blockquote

Python 2's python-serial is Python 3's python3-serial (note the python3) It can be installed from buster repositories as of this post.
It can also be installed from pip here:
pip3 install pyserial
If pip is not available on the machine then it can be installed from source:
https://github.com/pyserial/pyserial/releases
Download the archive, extract it and install it with:
python setup.py install

Related

Why do I get an error "[Errno 42] Illegal byte sequence" when trying to install pillow using pip?

I want to install pillow, but when I run pip install pillow in the cmd I get the following message:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pillow
Downloading https://files.pythonhosted.org/packages/5e/b6/8960697526a79bd1cb4520293078be3a10d725f23f20abbee298ebdeaabd/Pillow-6.2.2-cp27-cp27m-win_amd64.whl (1.9MB)
|ERROR: Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence
WARNING: You are using pip version 19.2.3, however version 20.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Python 3.8.2 is already installed on my computer and I added it to PATH.
I also ran python -m pip install --upgrade pip and nothing has changed.
What is the problem? Do I need to update the Python version?
Installation using third party PPA repository
Step 1: First install the Ubuntu software properties package if it’s not already installed on your system.
$ sudo apt update
$ sudo apt install software-properties-common
Step 2: After that run the commands to add the PPA.
$ sudo add-apt-repository ppa:deadsnakes/ppa
Step 3: Finally, run below to install Python 3.8
$ sudo apt update
$ sudo apt install python3.8
You can check as below:
$ python3 --version
Python 3.8.1
OK done.
Don't use the pip, pip3, etc. scripts ever. Instead always prefer the more explicit and surefire way of calling pip's executable module for a specific instance of the Python interpreter, for example:
path/to/pythonX.Y -m pip install Pillow
References:
https://snarky.ca/why-you-should-use-python-m-pip/
https://snarky.ca/a-quick-and-dirty-guide-on-how-to-install-packages-for-python/
Check if Python3 is correctly installed by, for example, running python3 -V in the command-line (this will show you the installed version)
This should show something like Python 3.8 ...
If you get an error here, like it is an unknown command, something probably went wrong during the installation...
Run pip3 install pillow to install pillow (Python 3)
Kindly download it at Python official website.
There is an option to update your version during the installation which is very useful.

Problem when installing google-cloud-speech python API in raspberry pi 3 (Jessie) via pip

I'm trying to install the google-cloud-speech python API for raspberry pi 3 (raspbian Jessie) using pip (1.5.6). I follow the instructions given by:
https://cloud.google.com/speech-to-text/docs/reference/libraries?authuser=1#client-libraries-install-python
but when installing the library using pip:
pip install --upgrade google-cloud-speech
I get this error:
error in grpcio setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
and the installation doesn't finish. The same job worked for me some months ago, so I guess some changes was made. Any ideas?
I've already tried upgrading pip
Start with upgrading installation tools:
pip install --upgrade setuptools pip
Upgrade your setup tools/ pip
pip install setuptools -U
Thank you all! now it is working. I'm pretty sure I tried before one of:
pip install --upgrade setuptools pip
pip install setuptools -U
But the thing is that executing both of them the installation finished correctly.

How to completely reset everything Python to default in Ubuntu 18.04?

Edit:
So now which pip, which python and which python3 have started working correctly somehow. I was also able to install libraries using pip. The only remaining problem is that of the apt_pkg. Running apt-get install python-apt gives:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-apt is already the newest version (1.6.3ubuntu1).
Running any python application still gives error: ImportError: No module named apt_pkg
Running echo $PATH returns:
/home/hamza/bin:/home/hamza/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Running find /usr -name python -o -name python3 returns:
/usr/local/lib/python3.5/dist-packages/notebook/static/components/codemirror/mode/python
/usr/local/lib/python2.7/dist-packages/notebook/static/components/codemirror/mode/python
/usr/lib/python3
/usr/lib/gimp/2.0/python
/usr/lib/libreoffice/share/Scripts/python
/usr/lib/virtualbox/sdk/bindings/xpcom/python
/usr/lib/wx/python
/usr/bin/python
/usr/bin/python3
/usr/share/code/resources/app/extensions/python
/usr/share/bash-completion/helpers/python
/usr/share/bash-completion/completions/python
/usr/share/bash-completion/completions/python3
/usr/share/python
/usr/share/javascript/codemirror/mode/python
/usr/share/python3
/usr/share/lintian/overrides/python
/usr/share/lintian/overrides/python3
/usr/share/gcc-8/python
/usr/share/gdb/python
/usr/share/librevenge/python
/usr/share/doc/python
/usr/share/doc/python3
/usr/share/doc/python-statsmodels/examples/python
/usr/share/playonlinux/python
Original:
Python on my system is a wreck. I have got multiple versions installed. None work properly. Apparently some applications using python are not working either (eg: Unity Tweaks). My python libraries will not install because pip doesn't work, although it says it is already installed
I was trying to install some libraries for python on my system using pip. Turned out pip was not working. I tried to reinstall pip only to learn that pip was already installed. I went through a process of understanding the difference between python and python3. I have tried enough things and have basically lost track of the things I have done to get the libraries installed. Long story short, pip does not work no matter what, my libraries will not install and consequently my code doesn't run.
Here is some of the things I have already done:
which pip
This return no output
apt-get install python-pip
Says I have pip already installed
apt-get install python-apt
To resolve ImportError: No module named apt_pkg. It says:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-apt is already the newest version (1.6.3ubuntu1).
But the error persists
And countless other stuff I do not remember.
What I want now is simple. I wish to somehow get out of this hassle by resetting all of my python settings and installation to default, and then install the pandas and numpy libraries for my system. Any and all help would be appreciated.
Result for python -m pip -V:
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Result for python3 -m pip -V:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
One of the following commands worked for me:
pip3 install -U pip
python -m pip install -U pip
python3 -m pip install -U pip
Make sure the version of your python3 is 3.6, which is the default version of ubuntu18, then upgrade pip.
export py3_path=`which python3`
rm $py3_path
ln -s `which python3.6` $py3_path
python3 -m pip install -U pip
Or use pyenv to manage multi versions https://github.com/pyenv/pyenv

Python pip installation in ubuntu

I am new to Ubuntu and was trying to install pip using get-pip.py , when I received this message.
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist- packages/pip-8.1.2-py2.7.egg
But when I enter pip -V, I receive an error saying :
The 'pip==7.1.0' distribution was not found and is required by the application
Complete error
I was trying to install new packages using pip install <packagename> but this command gives the same error as previous .
I suggest installing pip using the package manager. Open up a terminal and enter
sudo apt-get install python-pip
That should install the pip ubunutu package.
You should not be installing pip for the default python installation, neither from the package manager nor using get-pip.py. So you can never use it to break the system python.
Instead always use virtualenv (created from the default/system python or from a newer version), activate and use pip in that environment.

Python 3: ImportError "No Module named Setuptools"

I'm having troubles with installing packages in Python 3.
I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get:
importerror "No Module named Setuptools"
I have no idea what to do because I didn't have setuptools installed in the past. Still, I was able to install many packages with setup.py install without setuptools. Why should I get setuptools now?
I can't even install setuptools because I have Python 3.3 and setuptools doesn't support Python 3.
Why doesn't my install command work anymore?
Your setup.py file needs setuptools. Some Python packages used to use distutils for distribution, but most now use setuptools, a more complete package. Here is a question about the differences between them.
To install setuptools on Debian:
sudo apt-get install python3-setuptools
For an older version of Python (Python 2.x):
sudo apt-get install python-setuptools
EDIT: Official setuptools dox page:
If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from
python.org, you will already have pip and setuptools, but will need to
upgrade to the latest version:
On Linux or OS X:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
Therefore the rest of this post related to Distribute is obsolete (e.g. some links don't work).
EDIT 2022-02-04
From Python 3.10 Distutils is deprecated and will be removed in Python 3.12 - use setuptools:
The entire distutils package is deprecated, to be removed in Python 3.12. Its functionality
for specifying package builds has already been completely replaced by
third-party packages setuptools and packaging ...
Distribute (deprecated)
Distribute - is a setuptools fork which "offers Python 3 support". Installation instructions for distribute(setuptools) + pip:
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
Similar issue here.
UPDATE: Distribute seems to be obsolete, i.e. merged into Setuptools: Distribute is a deprecated fork of the Setuptools project. Since the Setuptools 0.7 release, Setuptools and Distribute have merged and Distribute is no longer being maintained. All ongoing effort should reference the Setuptools project and the Setuptools documentation.
You may try with instructions found on setuptools pypi page (I haven't tested this, sorry :( ):
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
easy_install pip
Make sure you are running the latest version of pip
I tried to install Ansible and it failed with
ModuleNotFoundError: No module named 'setuptools_rust'
python3-setuptools was already in place, so upgrading pip solved it.
pip3 install -U pip
I was doing this inside a virtualenv on Oracle Linux 6.4 using Python 2.6, so the apt-based solutions weren't an option for me, nor were the Python 2.7 ideas. My fix was to upgrade my version of setuptools that had been installed by virtualenv:
pip install --upgrade setuptools
After that, I was able to install packages into the virtualenv.
The solution which worked for me was to upgrade my setuptools:
python3 -m pip install --upgrade pip setuptools wheel
For others with the same issue due to a different reason: This can also happen when there's a pyproject.toml in the same directory as the setup.py, even when setuptools is available.
Removing pyproject.toml fixed the issue for me.
pip uninstall setuptools
and then:
pip install setuptools
This works for me and fixes my issue.
When there's a pyproject.toml in the same directory as the setup.py, it can be the cause of the issue. I renamed that file, but it didn't solve the issue, so I restablished the original file name, and did the following change.
Under the [build-system] section, I added "setuptools" to the requires= list, and it worked.
First step #1
You have to install setuptools
On Linux:
pip install -U pip setuptools
On Mac OS:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
Second step #2
Make sure you have made it accessible (make it available in environmental variables)
On Linux
export PATH="INSTALLATIONDIRECTORY:$PATH"
On Mac OS
Sorry, I don't know.
On Windows
Open the Start Search, type in “env”, and choose “Edit the system environment variables”
Click the “Environment Variable” button.
Set the environment variables as needed. The New button adds an additional variable.
Dismiss all of the dialogs by choosing “OK”. Your changes are saved!
The distribute package provides a Python 3-compatible version of setuptools: http://pypi.python.org/pypi/distribute
Also, use pip to install the modules. It automatically finds dependencies and installs them for you.
It works just fine for me with your package:
[~] pip --version
pip 1.2.1 from /usr/lib/python3.3/site-packages (python 3.3)
[~] sudo pip install ansicolors
Downloading/unpacking ansicolors
Downloading ansicolors-1.0.2.tar.gz
Running setup.py egg_info for package ansicolors
Installing collected packages: ansicolors
Running setup.py install for ansicolors
Successfully installed ansicolors
Cleaning up...
[~]
this is how my problem was solved => pip3 install setuptools-rust
If you want to check your list => pip3 list
i faced this problem while trying to install elastalert2
System informations
CentOS Linux release 7.9.2009 (Core)
Python 3.6.8
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
I ran into this problem when my pip requirements.txt file contained an editable library that was built using poetry and contained a pyproject.toml file. Following the documentation for setuptools, my solution was to add setuptools to the build-system requirements in the pyproject.toml file as follows:
[build-system]
requires = ["poetry-core>=1.0.0", "setuptools"]
build-backend = "poetry.core.masonry.api"
If pip isn't installed, like for example if it's coming from the Deadsnakes PPA, or a Docker environment, the best way to fix this error is by bootstrapping it by running
python -m ensurepip
Windows 7:
I have given a complete solution here for Python Selenium WebDriver:
Setup easy install (Windows - simplified)
download ez.setup.py (https://bootstrap.pypa.io/ez_setup.py) from 'https://pypi.python.org/pypi/setuptools'
move ez.setup.py to C:\Python27\
open cmd prompt
cd C:\Python27\
C:\Python27\python.exe ez.setup.py install
I ran sudo python setup.py build_ext -i and it failed with No module named setuptools.
I solved it with this command:
<i>sudo apt-get install python-setuptools</i>
A few years ago I inherited a Python (2.7.1) project running under Django-1.2.3 and now was asked to enhance it with QR possibilities. I got the same problem and did not find pip or apt-get either. So I solved it in a totally different, but easy way.
I /bin/vi-ed the setup.py and changed the line
"from setuptools import setup"
into:
"from distutils.core import setup"
The PyPA recommended tool for installing and managing Python packages is pip. pip is included with Python 3.4 (PEP 453), but for older versions here's how to install it (on Windows):
Download https://bootstrap.pypa.io/get-pip.py
>c:\Python33\python.exe get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
>c:\Python33\Scripts\pip.exe install pymysql
Downloading/unpacking pymysql
Installing collected packages: pymysql
Successfully installed pymysql
Cleaning up...
On macOS, if you have homebrew installed, simply run:
brew install rust
If you still find this issue, try this:
python3 -m pip install scrapy --upgrade --force --user
While trying to install socketIO I had the same issue. At my system (Windows 11) setupTools were there twice. At C:\Program Files\Python310\Lib\site-packages\ and at C:\Users\user\AppData\Roaming\Python\Python310\site-packages\
Had to uninstall one of them.
Working on Debian, sometime it can be because of older pip version. Therefore, update pip>
python -m pip install -U pip
I had such a problem to install pyunicorn. I wanted to install it on Google Colab. I tried installing pyunicorn directly from Github and it worked for me. For example in my case it was like this:
pip install git+https://github.com/pik-copan/pyunicorn.git#egg=pyunicorn

Categories

Resources