pip3 installation issue using linux - pip

I tried around 8 hours to install pip3- python in ubintu but its not working showing:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in
from pip import main
File "/usr/lib/python3/dist-packages/pip/init.py", line 29, in
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/init.py", line 23, in
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.9/distutils/init.py)
i did
sudo apt-get update
sudo apt-get -y install python3-pip
pip3 --version
after this step the error message in the above shown

Related

pip3 TypeError: deprecated() got an unexpected keyword argument 'name' [duplicate]

I am trying to install few packages and started getting an error. Then used multiple commands in ubuntu to update few things but errors are similar
pip install -U pip setuptools
or
python3 -m pip install --upgrade pip
or
sudo -H pip3 install --upgrade pip
Following is the error sample
user#machine:~$ pip install cryptography
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
from pip._internal.exceptions import CommandError
File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
from pip._vendor.six import iteritems
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 65, in <module>
vendored("cachecontrol")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
.
.
.
.
File "<frozen zipimport>", line 259, in load_module
File "/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
File "/home/dhome/.local/lib/python3.8/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import SSL, crypto
File "/home/dhome/.local/lib/python3.8/site-packages/OpenSSL/SSL.py", line 19, in <module>
from OpenSSL.crypto import (
File "/home/dhome/.local/lib/python3.8/site-packages/OpenSSL/crypto.py", line 3224, in <module>
utils.deprecated(
TypeError: deprecated() got an unexpected keyword argument 'name'
I have updated the system with apt-get install libffi-dev python-dev python3-dev and
apt-get install build-essential libssl-dev already as suggested in here
Something got broken down in OpenSSL and no command was working with pip afterwards. I was even unable uninstall pip.
I removed installation files manually (most likely not a recommended approach) with
sudo rm -rf /usr/local/lib/python3.8/dist-packages/OpenSSL
sudo rm -rf /usr/local/lib/python3.8/dist-packages/pyOpenSSL-22.1.0.dist-info/
and reinstalled using pip3 install pyOpenSSL==22.0.0. The other version was having some issue as described here.
For me even uninstall of pyOpenSSL was encountering same error TypeError: deprecated() got an unexpected keyword argument 'name'
so first I upgraded pip to 23.0 ,uninstall PyOpenSSL,manually deleted openSSL folder from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages then installed PyOpenSSL 20.0.0, finally issue resolved.

./odoo-bin --config=' /etc/odoo.conf' ODOO 11

Traceback (most recent call last):
File "./odoo-bin", line 5, in <module>
import odoo
File "/opt/odoo/odoo/odoo/__init__.py", line 88, in <module>
from . import service
File "/opt/odoo/odoo/odoo/service/__init__.py", line 7, in <module>
from . import wsgi_server
File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 25, in <module>
import werkzeug.contrib.fixers
ModuleNotFoundError: No module named 'werkzeug.contrib'
After tracing back errors, I got this error.
Failed building wheel for pyldap
And after I run this code.
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
and
pip3 install -r requirements.txt
Make sure your werkzeug version in requirements.txt is 0.11.15.
If not 'pip3 install werkzeug==0.11.15'
then you can execute odoo
I ran into the same issue when trying to use Proxyfix in werkzeug==1.0.0
Since that Werkzeug 1.0.0 has removed deprecated code from werkzeug.contrib, ProxyFix was relocated to werkzeug.middleware.proxy_fix
To fix the ModuleNotFoundError: No module named 'werkzeug.contrib' Error:
You should import ProxyFix with the following code:
from werkzeug.middleware.proxy_fix import ProxyFix
I hope this helps and fix your issues 😄

basic mlxtend example giving invalid syntax error

I'm using Python 3.5.2 on Ubuntu 16.04.
I've installed sklearn using..
sudo apt install python-sklearn
and mlxtend using...
sudo pip3 install mlxtend
I'm trying to run the basic Iris example found on the Internet, but I am getting an error as soon as I try to import plot_decision_regions from mlxtend.plotting:
from mlxtend.plotting import plot_decision_regions
Traceback (most recent call last):
File "scripts/machine.learning.py", line 6, in <module>
from mlxtend.plotting import plot_decision_regions
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/__init__.py", line 15, in <module>
from .heatmap import heatmap
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/heatmap.py", line 74
raise AssertionError(f'len(row_names) (got {len(row_names)})'
^
SyntaxError: invalid syntax
I had the same error, just upgrade to python3.7 the real error is
python 3.5 does not support f prefix
upgrade using conda
conda install -c anaconda python=3.7
and then update all depencies
conda update --all
I'm not seeing the same error as you, but try remove legend=range(105, 150) from plot_decision_regions i.e.
plot_decision_regions(x_combined, y_combined, clf=tree)
I'm using the latest current sklearn, i.e.
import sklearn
sklearn.__version__
'0.21.3'
Perhaps remove that version
sudo apt-get remove python-sklearn
Then install via pip, i.e.
pip3 install scikit-learn

upgrade pip and error on centOS7

My system is CentOS7, I install python2.7.13, and then install pip. when I install pip7.0.1, it's ok. But after I update to pip9.0.1, when I use the command pip, it runs to errors.
File "/usr/local/python2.7.13/bin/pip", line 7, in
from pip import main
File "/usr/local/python2.7.13/lib/python2.7/site-packages/pip/init.py", line 28, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/python2.7.13/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 9, in
from pip.download import path_to_url
File "/usr/local/python2.7.13/lib/python2.7/site-packages/pip/download.py", line 36, in
from pip.utils.glibc import libc_ver
File "/usr/local/python2.7.13/lib/python2.7/site-packages/pip/utils/glibc.py", line 4, in
import ctypes
File "/usr/local/python2.7.13/lib/python2.7/ctypes/init.py", line 7, in
from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes.
Thanks for any help.
I have solved my problem by myself. I have tried install pip by get-pip.py, easy_install and source code. And easy_install was installed by setuptools. But the pip doesn't work. In the end, I install easy_install by distribute_setup.py
and then install pip by easy_install. Pip works correctly now.

How can I use jython setup.py install?

I am using a Jython virtualenv where I can install whatever software via pip or via easy_install, but there is a software that is not registered yet and the installation mode via:
[sudo] python setup.py install
and I am trying to do the same with jython:
[sudo] jython setup.py install
So, I am getting these follow errors:
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
I checked and installed jython ez_setup.py again.
I downloaded the yolk and didn't solved too.
My folder:
╭─hudson#hudson-pc ~/jython2.7a1/Lib/site-packages ‹› ‹master*›
╰─$ ls
easy-install.pth setuptools.pth yolk 0.4.3-py2.7.egg README should_dsl-2.0a5-py2.7.egg setuptools-0.6c11-py2.7.egg virtualenv-1.7.2-py2.7.egg
And at the normal(real) environment, without virtualenvs, I got the same erros.
At Python I already installed this software and worked well.
If I enter at Jython Shell and try import setuptools, I got the same erros too:
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>> import sys
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__']
Then, I add the site-packages to the sys (It can be a stupid attempt):
>>> sys.path.append('/home/hudson/jython2.7a1/Lib/site-packages')
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__', '/home/hudson/jython2.7a1/Lib/site-packages']
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
Why is not recognizing?
If pip "works" then you could use it to install your software. To try it, run from a directory with setup.py:
$ pip install -e .
If you have a tarball of the package:
$ pip install your_package-0.0.1.tar.gz
pip can install from a git repository, use custom urls from where to get packages, etc.
I've tested it: jython works with virtualenv, distribute (a fork of setuptools), pip. So jython can install a package if it uses setuptools in setup.py.
Basically you need to install the installtool first. To do so see the doc linked below.
install this: http://peak.telecommunity.com/dist/ez_setup.py
(see here:http://www.jython.org/jythonbook/en/1.0/appendixA.html#setuptools)

Resources