Unable to run pip3 - ModuleNotFoundError - python

I am using Ubuntu 18.04 and Python3.7.1. I am trying to run pip3, but I get an error with the lsb_release program:
$ pip3 -V
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.distro'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
...
File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 932, in _get_lsb_release_info
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.
I don't see what's wrong, the file starts with the right header:
#!/usr/bin/python3 -Es
I can see pip3 is actually there:
$ whereis pip3
pip3: /usr/bin/pip3 /usr/share/man/man1/pip3.1.gz
I tried uninstalling and reinstalling pip3, but nothing changed.
EDIT:
This solved my problem:
https://askubuntu.com/a/1003535/619372

Related

Problems with installing packages with Anaconda

I tried installing pandas_datareader in Anaconda using conda install -c anaconda pandas-datareader. It gives me this result:
Traceback (most recent call last):
File "C:\Users\Peter\Anaconda3\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pywin32_bootstrap'
Remainder of file ignored
Error processing line 7 of C:\Users\Peter\Anaconda3\lib\site-packages\pywin32.pth:
Traceback (most recent call last):
File "C:\Users\Peter\Anaconda3\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pywin32_bootstrap'
Remainder of file ignored
Okay, bad luck I thought, and I tried installing something else (plotly). And this gave me exactly the same result.
Try:
conda remove [-c anaconda] pywin32
conda install -c anaconda pywin32
Code in brakets is not necessary.
This should reinstall pywin32. And go for another try. It worked for me using pip.

ModuleNotFoundError:No module named '__builtin__' in conda

I have looked at other answers such as conda install future and others but none seem to solve this error. Everything was working till yesterday but today when I am trying to run my script I get this error.
I initially thought that I had multiple pandas packages from pip and conda so I uninstalled from both and then installed via conda again. But the error still persists.
I have installed python 3.6 as a separate environment in anaconda 2.
Traceback (most recent call last):
File "/Users/amit/anaconda2/envs/python36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 49, in <module>
import __builtin__ as builtins
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 18, in <module>
from nameserver import NameServer
File "/Users/amit/Work/ml/marl/nameserver.py", line 4, in <module>
import pandas as pd
File "/Users/amit/anaconda2/envs/python36/lib/python3.6/site-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/Users/amit/anaconda2/envs/python36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 62, in <module>
import http.client as httplib
ModuleNotFoundError: No module named 'http.client'
=============
EDIT 1
Following #EvgenyPogrebnyak's advice I created a new env named py36. I tried running the print statement python -c "import pandas as pd; print(pd.__version__)" statement from the home directory or infact any other directory it runs fine but when I run it from my project directory I get this particular error, which is weird.
amit:~ $source activate py36
(py36) amit:~ $python -c "import pandas as pd; print(pd.__version__)"
0.23.0
(py36) amit:~ $cd Work/ml/marl/
(py36) amit:~/Work/ml/marl $python -c "import pandas as pd; print(pd.__version__)"
Traceback (most recent call last):
File "/Users/amit/anaconda2/envs/py36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 49, in <module>
import __builtin__ as builtins
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/amit/anaconda2/envs/py36/lib/python3.6/site-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/Users/amit/anaconda2/envs/py36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 62, in <module>
import http.client as httplib
ModuleNotFoundError: No module named 'http.client'
I think code below should run. Exit enviornments is you are in one before running.
conda create -n new1 python=3.6 pandas
source activate new1
python --version
# expected:
# Python 3.6.0 :: Anaconda 4.3.0 (32-bit)
python -c "import pandas as pd; print(pd.__version__)"
# expected '0.22.0',but more importantly this shows pandas in imported
Does this run? You can install more libraries requred with conda install -n new1 <package> then try:
python /Users/amit/Work/ml/marl/nameserver.py
Similar result can be achieved with pipenv.

Using Python 3 when Python 2.7 is default, pip install error

I originally had both python 2.7 and python 3 installed with python 2.7 as my default in PATH. I needed to run a script using python 3 but could not set it as my default python in PATH for some reason. After just uninstalling python 2.7 I opened 3 and ran the command python get-pip.py install which gave me this error
C:\Python30>python get-pip.py install
Traceback (most recent call last):
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\compat\__init__.py", line 16, in <module>
ImportError: cannot import name OrderedDict
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "get-pip.py", line 19177, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\__init__.py", line 14, in <module>
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\utils\__init__.py", line 22, in <module>
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\compat\__init__.py", line 18, in <module>
File "c:\users\jacob\appdata\local\temp\tmplqxvtx\pip.zip\pip\compat\ordereddict.py", line 25, in <module>
ImportError: No module named UserDict
I already tried python -m pip install (module name) but it returns No module named pip
I assume you use windows, so here is an answer how to install pip on windows:
how-do-i-install-pip-on-windows
On Linux you could just type:
sudo apt install python-pip

PyKCS11 installation

I want to install and use PyKCS11 to my mac (via terminal). I want to use python3 for the whole process. I downloaded it from here: https://bitbucket.org/PyKCS11/pykcs11.
I have python3 installed at /usr/local/lib. I downloaded the folder, ran make build, and everything was ok. When i run make install i get the following:
python3 setup.py install --prefix=/usr/local --root=/
running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/lib/python3.4/site-packages/PyKCS11-1.3.2-py3.4.egg-info
Writing /usr/local/lib/python3.4/site-packages/PyKCS11-1.3.2-py3.4.egg-info
(*Removing... is from the previous time i executed the command)
After that, i open python3 and execute import PyKCS11
and i get the following error:
>>> import PyKCS11
Traceback (most recent call last):
File "/Users/Dkostas/Desktop/tools/PyKCS11/PyKCS11/LowLevel.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_LowLevel', [dirname(__file__)])
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_LowLevel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Dkostas/Desktop/tools/PyKCS11/PyKCS11/__init__.py", line 20, in <module>
import PyKCS11.LowLevel
File "/Users/Dkostas/Desktop/tools/PyKCS11/PyKCS11/LowLevel.py", line 28, in <module>
_LowLevel = swig_import_helper()
File "/Users/Dkostas/Desktop/tools/PyKCS11/PyKCS11/LowLevel.py", line 20, in swig_import_helper
import _LowLevel
ImportError: No module named '_LowLevel'
Could it be a problem that python3 cannot use swig?
Python2 is installed at a different location (/usr/lib/python2.7)
I used Homebrew to install python.
Any ideas appreciated.
Thanks in advance!
you need to come out from PyKCS11 directory and for more info check the below link
https://github.com/LudovicRousseau/PyKCS11/issues/70

import error when trying to use pip command in ubuntu terminal

I just installed pip with ubuntu onto my laptop. Whenever I try to use pip in the terminal, I keep getting this error:
lopuj#lopuj-Dell-System-XPS-L502X:~$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 357, in load_entry_point
def get_entry_info(dist, group, name):
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2394, in load_entry_point
break
File "/usr/local/lib/python3.4/dist-packages/setuptools-1.1.5-py3.4.egg/pkg_resources.py", line 2108, in load
name = some.module:some.attr [extra1,extra2]
ImportError: No module named 'pip'
lopuj#lopuj-Dell-System-XPS-L502X:~$ ^C
lopuj#lopuj-Dell-System-XPS-L502X:~$
How can I stop this from happening so i can just type in commands like 'pip install Django==1.7.1'?
Your referencing
usr/local
but pip is installed at
usr/lib
Check your installation. I would reinstall using esay_install and then open/close terminal.

Categories

Resources