Cannot uninstall python/pip on raspberry pi 3 b+ - python

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.

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.

Install virtual environment fails on Ubuntu16.4

I am trying to install virtual environment on my Ubuntu and my python is 3.5. My command is:
python3 -m venv my-env/
It reminds me to install python3-venv first, but then got the following error.
apt-get install python3-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-venv is already the newest version (3.5.1-3).
0 upgraded, 0 newly installed, 0 to remove and 95 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Setting up cython3 (0.23.4-0ubuntu5) ...
Traceback (most recent call last):
File "/usr/bin/py3compile", line 34, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
ImportError: No module named 'debpython'
dpkg: error processing package cython3 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
cython3
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is this because Python3.5 doesn't work with python3 -m venv? If I can't upgrade python3.5, what can I do?
You can't use apt-get install without root/sudo. Yeah you can jump through hoops but ignoring that.
You can use anaconda-python without root. That would be a separate python from the system one with likely a different version. And that's a subject for another question
Your locales are messed up
Yeah the error mesg could be better
Added later
Why venv is absent from builtin-python I'm not clear; it's supposed to be there 3.3 onwards
Pip is alternative to apt and by default works for user — sudo not required.
You can get pip by hand but it's fiddly and ill-advised
However the pip module should work even if the command is not available ie use
python3 -m pip where you were using just pip

importing pycurl with libcurl4 raises ImportError

I am using Ubuntu 18.04. If I install libcurl4 (instead of libcurl3), when I import pycurl installed with pipenv I get
>>> import pycurl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/pietro/envs/try_fabric-kcbGLH3z/lib/python3.6/site-packages/pycurl.cpython-36m-x86_64-linux-gnu.so)
Note that this error is raised only when I use a pycurl installed with pipenv or pip. If I use instead pycurl installed through apt on system python there are any errors...
What can I do to avoid this impasse?
I assume you upgraded your operating system recently.
pip stores a cache of built wheels in your home directory, when upgrading your os it is a good idea to clear this cache as the binaries may now link against incompatible system libraries
You can do this by rm -rf ~/.cache/pip and then recreate your environment

Trying to install J3DView

After entering the following in the command line:
sudo apt-get install python3 python3-dev python3-pip
sudo pip3 install cx_Freeze Cython PyOpenGL PyOpenGL_accelerate
sudo python3 setup.py install_exe
The last command gives me this error:
Could not import cx_Freeze. Building executable not possible.
Traceback (most recent call last):
File "setup.py", line 13, in <module>
from Cython.Build import cythonize
ImportError: No module named 'Cython'
Any ideas why?
I'm using Linux Mint 17.3 'Rosa' Cinnamon 64-bit.
[EDIT]
This problem was a complete mess and I still have no clue what happened before. I have given up trying to get Python to work, as I have found an application that does the same thing as the Python application I was trying to get working. It's such a pain.

python import error in gzip.py ; where is zlib

I am running Ubuntu 12.10 that has python 2.7 as its default. I have installed python 3.3 in /opt/python3.3 (using ./configure --prefix=/opt/python3.3) and have created a symlink /usr/bin/python33 that points to the executable in /opt. There is already a symlink /usr/bin/python3 that points to the python 3.2 (actually it points to python3.2mu: if you can explain as a side note as to why this 'mu' is included :) ) installation that came with the ubuntu installation.
I installed distribute tools using python3 without any problems. But when I tried the same thing with python33 it gave me the following error:
ankur#junk-mechanism:~$ sudo python33 distribute_setup.py
Extracting in /tmp/tmp685lyf
lzma module is not available
not a bzip2 file
gzip module is not available
bad checksum
Traceback (most recent call last):
File "distribute_setup.py", line 550, in <module>
sys.exit(main())
File "distribute_setup.py", line 547, in main
return _install(tarball, _build_install_args(options))
File "distribute_setup.py", line 78, in _install
tar = tarfile.open(tarball)
File "/opt/python3.3/lib/python3.3/tarfile.py", line 1578, in open
raise ReadError("file could not be opened successfully" + str(name) + repr(fileobj))
tarfile.ReadError: file could not be opened successfully/home/ankur/distribute-0.6.35.tar.gzNone
So in tarfile.py, the classmethod Tarfile.open calls the class method Tarfile.gzopen where the module gzip is imported:
try:
import gzip
gzip.GzipFile
except (ImportError, AttributeError):
raise CompressionError("gzip module is not available")
The error raised here is ImportError because gzip.py has an import zlib which it cant find. But even the other installations of python (2.7 and 3.2) dont contain zlib in the respective standard lib /usr/lib/pythonx.x/lib/. So what is the difference?
It sounds like you didn't build everything because of missing dependencies. You can try getting the missing dependencies and rebuilding. To get the missing dependencies, I'd just work from what Python 3.2 requires and do:
sudo apt-get build-dep python3
Then you can reconfigure and rebuild Python 3.3 to get all the required modules.
Another option is to use the dead snakes ppa:
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3
I usually install the -dev package too so that I can install packages that have C extension modules:
sudo apt-get install python3.3-dev

Categories

Resources