pythonbrew importing bz2 yields: ImportError: No module named '_bz2' - python

This wtf happens on a Debian, during some dumb pip install, in python3.4.1
Traceback (most recent call last):
File "/home/pi/.pythonbrew/pythons/Python-3.4.1/lib/python3.4/tarfile.py", line 1640, in bz2open
import bz2
File "/home/pi/.pythonbrew/pythons/Python-3.4.1/lib/python3.4/bz2.py", line 20, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named '_bz2'
Unless someone nails this early & easy, I will return next year to emblandish it with boredom like which RaspberryPI Debian it is.
Anyhoozle, the junior answer is apt-get install libbz2-dev tx to #falsetru for finishing the FAQ segments of tonight's entertainment. However, we seem to have aptitude installed a bunch of random filenames ending in -dev recently:
$ aptitude search libbz2
i libbz2-1.0
i libbz2-dev
So now I gotta make the question harder. If I guess the RaspberryPi itself is not at fault (this sh*t swings like Tarzan on my WinPython3.3, 64-beet), then maybe pythonbrew dunnit.

You need to install libbz2-dev package before install Python to build bz2 module.
apt-get install libbz2-dev

The "winning" answer is to erase your .pythonbrew folder and build again. Put another way, Python had trouble seeing Aptitude -dev packages installed after pythonbrew built it.
Nobody upvote it plz, bc it's still just a sucky workaround!

Related

how to install cpp man page on debian 10?

from here: https://stackoverflow.com/questaions/34507045/how-to-install-man-pages-for-c11 there is mentioned,
cppman is no longer supported under Ubuntu/apt
and therefor no libstdc++6-<version>-doc could be install via apt anymore.
and the only way to install the man page is via pip3. So I have tried to install
sudo apt-get install python-pip and sudo apt-get install python3-pip. Now, having python3, I can install it via pip3:
pip3 install cppman, everything seems correct, before I tried to cache the man pages: cppman -c, which giver error:
Traceback (most recent call last):
File "/usr/local/bin/cppman", line 40, in <module>
from cppman.main import Cppman
File "/usr/local/lib/python2.7/dist-packages/cppman/main.py", line 26, in <module>
import html
ImportError: No module named html
As could be seen, it uses Python2.7 instead of Python3, that is strange.
From github, I have found similar problem here: https://github.com/aitjcize/cppman/issues/80, where they suggest to do
pip uninstall mancpp
pip3 install mancpp
Which I did, but when installing mancpp again from pip3, then another server error:
Collecting mancpp
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/mancpp/
So what now? If you read till here, than you can see there are many errors, but cannot find solution anywhere in stack sites. I only want to have cpp manuals for searching for functions and classes (like std) and mainly for glibc++. As I could do simply with c functions. Why is it so hard? Anyway, how to install the mancpp via pip3?
uname -a:
Linux 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
The script uses #!/usr/bin/env python shebang and on your system python is most probably 2.7. Just edit the script:
sudo vim /usr/local/bin/cppman
Append 3 at the end: #!/usr/bin/env python3 and try again.

Cannot uninstall python/pip on raspberry pi 3 b+

I am working on a raspberry pi 3B+. I want to upgrade the python from 2.7 to 3.6.
I downloaded the python 3.6 extracted and made it, However it got installed in the /usr/local/bin.
I tried to make it again this time by specifying ./configure --prefix=/usr prefix however the make gave a traceback error.
I also tried update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2 which helps in changing versions of python.
However, after doing so, my pip is not working now.
I have the following files in /usr/local/bin:pip,pip2.7,pip3,pip3.5,pip3.6.
I tried removing pip so that i can reinstall it using sudo apt-get remove python-pip but it gives the following error:
pi#raspberrypi:/usr/local/bin $ sudo apt-get remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libpython-all-dev python-all python-all-dev python-keyring
python-keyrings.alt python-secretstorage python-wheel
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
python-pip
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
1 not fully installed or removed.
After this operation, 671 kB disk space will be freed.
Do you want to continue? [Y/n] y
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 29, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
(Reading database ... 138007 files and directories currently installed.)
Removing python-pip (9.0.1-2+rpt2) ...
File "/usr/bin/pyclean", line 63
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing package python-pip (--remove):
subprocess installed pre-removal script returned error exit status 1
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
python-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
which suggests that apt_pkg (or some problem with apt-get).
when i do pip --version , i get:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
I just want to have python 3.6 and 2.7(since i have already installed libraries on 2.7) with functional pip.
Why don't you install miniconda for ARM and get Python and all important packages at once ?
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh
sudo md5sum Miniconda3-latest-Linux-armv7l.sh
sudo /bin/bash Miniconda3-latest-Linux-armv7l.sh
sudo reboot -h now
I think you aren't aware that most linux distros come shipped with python2 AND python3. By typing python and pip you will use your operating systems python2 and pip2 version.
What you probably want is using python3 and pip3 instead.
Something like "upgrading" from python2 to python3 is not possible because it's a fundamental difference and they are incompatible. This is why you have both installed.
Uninstalling or upgrading your systems python interpreter is a terrible bad idea, because your system needs them. For professional usage you should think about version control again, but for your first (and second) steps in python it's totally fine to use the preinstalled python interpreter of your OS.
Solutions like pyenv or virtualenv are very powerfull tools, but you probably don't want to start with it.

Installing Python libraries manually on Raspbian

I'm working with reading sensor values through a Raspberry Pi 3 using Python, and I'm currently using this library: https://github.com/szazo/DHT11_Python. I am fairly new to the language and since there are no instructions in the README on how to install this library, I was wondering if anyone knows how to do it manually? I would just like to get rid of this error:
Traceback (most recent call last):
File "sensorRead.py", line 4, in <module>
import dht11
ImportError: No module name 'dht11'
So far, I ran these commands:
sudo git clone https://github.com/szazo/DHT11_Python.git
cd DHT11_Python
sudo apt-get update
sudo apt-get install build-essential python-dev python-openssl
Then, I moved the library from /home/pi to /usr/lib but I'm still getting the same error. I must be missing something.
If anyone knows how to properly install this library, then please help! Thank you!
You just need to have your sensorRead.py file in the same folder as dht11.py

ImportError: No module named 'ase.build'

In ubuntu 16.04 i installed python and modules:
sudo apt install python3 python3-scipy python3-numpy python3-ase
then i try to follow the first tutorial on the ASE homepage. I run python3 in bash terminal, and can import other modules but not ase-build. It looks like this:
>>> from ase.optimize import QuasiNewton
>>> from ase.build import fcc111, add_adsorbate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'ase.build'
>>>
Using a python script throws an equivalent error.
What could be the problem?
UPDATE & SOLUTION
Seems this was not really even a python problem. I seem to have had some package dependency errors probably due to not running apt update in a long time between program installations. I removed python2.x and python 3.x, then iterated apt update, apt upgrade, apt autoremove, then reinstalled only python3. I installed python3-pip and installed the numpy, scipy, and ase packages using the proper form python3 -m pip install --upgrade <package>. Now everything works as expected.
Check what version of the library you have.
import ase
print(ase.__version__)
If the version is 3.10.0 then that is the problem since the build module appeared (as far as I know) in the 3.11.0 version.
Due to this link - you have installed the 3.9.1.4567-3 version on your computer.
But The asu.build has been added in:
commit 71c9563e423e2add645c26f8d0a722f3db13e135
Author: Jens Jørgen Mortensen
Date: Tue Apr 12 15:40:59 2016 +0200
Move stuff to ase.build module
So, the module asu.build doesn't exist in your version (3.9 has been released in 2015). You have to install the newer version of python3-asu.

Python 2.7 No module named _sqlite3 (no root access to machine, python is locally installed)?

There might be other questions similar to this but, in my particular case, I don't have super user (sudo) access to the machine and I have locally installed Python 2.7.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/spicmacay/.local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/spicmacay/.local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
>>>
UPDATE: When I run ./configure&& make, I get:
make
running build
running build_ext
building dbm using gdbm
INFO: Can't locate Tcl/Tk libs and/or headers
Python build finished, but the necessary bits to build these modules were not found:
_sqlite3 _tkinter bsddb185
dl imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
running build_scripts
Came to this issue also.. fixed by compiling Python and passing sqlite3 headers/libs during ./configure
Python 2.7.3 _sqlite3 module is not being built after passing headers/libraries
Posted just in case anyone else has this issue in the future and does not have sudo access to a node.
This happened me recently. You need to apt-get install libsqlite3-dev (on debian - sqlite-devel possibly elsewhere) and recompile python.
If you first ./configure sqlite3 with a --prefix option, then make and make install it and then use the same --prefix when compiling Python, the Python installation will be able to magically find and use the sqlite3 you just installed.
cd sqlite-autoconf-3080100
./configure --prefix=/home/xdanek7/appscale/local
make
make install
cd ../Python-2.7.6
./configure --prefix=/home/xdanek7/appscale/local
make
make install
Try adding sudo before the command apt-get install libsqlite3-dev to get rid of "NO root access"
i.e on terminal, write:
sudo apt-get install libsqlite3-dev

Categories

Resources