pip3 not installing packages - python

I enter the following line into terminal:
pip3 install numpy
this gives me:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 931, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout, stderr)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
Im thinking its a path issue but im not really sure.

This is a bug with the distro package vendored by pip. The bug has been solved but the latest version of pip uses and very old version of distro which doesn't have this bug fix applied.
For now, you can simply try to make the executable available in the path.

Related

pip3 "build" will not install

when I try to install build with
sudo pip3 install build
the following error occurs:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 386, in run
use_user_site=options.use_user_site,
File "/usr/lib/python3/dist-packages/pip/_internal/req/__init__.py", line 49, in install_given_reqs
**kwargs
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 760, in install
use_user_site=use_user_site, pycompile=pycompile,
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 382, in move_wheel_files
warn_script_location=warn_script_location,
File "/usr/lib/python3/dist-packages/pip/_internal/wheel.py", line 215, in move_wheel_files
prefix=prefix,
File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 153, in distutils_scheme
d.parse_config_files()
File "/usr/lib/python3.7/distutils/dist.py", line 406, in parse_config_files
parser.read(filename)
File "/usr/lib/python3.7/configparser.py", line 696, in read
self._read(fp, filename)
File "/usr/lib/python3.7/configparser.py", line 1091, in _read
fpname, lineno)
configparser.DuplicateOptionError: While reading from 'setup.cfg' [line 10]: option 'url' in section 'metadata' already exists
while installing the collected packages. The install never completes; pip says it was never installed. I would greatly appreciate any help troubleshooting.
In the off chance anyone else has this problem, I found a temporary fix that will probably make python stop working in a few days.. I went to ln 1088-1090 of /usr/lib/python3.7/configparser.py and replaced that bit about raising an exception after an if statement with
while (self._strict and
(sectname, optname) in elements_added):
elements_added.pop()
This seemed to have fixed the problem, albeit not in the most pretty method, as installation pf build and use of sdist now works ok.

Removed argparse.py

I use Ubuntu 18.04. By mistake, I changed argparse.py file in usr/lib/python3.6. I couldn't fix it and I thought to remove it, so I could reinstall. Now I can't reinstall, whenever I try "pip install argparse" I get an error like this:
Defaulting to user installation because normal site-packages is not writeable
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 279, in run
session = self.get_default_session(options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 74, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 91, in _build_session
index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 241, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 129, in user_agent from pip._vendor import distro
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py", line 37, in <module>
import argparse ModuleNotFoundError: No module named 'argparse'
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 105, in main return self._main(args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 224, in _main self.handle_pip_version_check(options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 146, in handle_pip_version_check timeout=min(5, options.timeout)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/req_command.py", line 91, in _build_session index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 241, in __init__self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/session.py", line 129, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py", line 37, in <module>
import argparse
ModuleNotFoundError: No module named 'argparse'
Could you please help me to fix this?
argparse is part of the standard library, not a third-party module. The standard library is not managed via pip (that is both its blessing and its bane).
So you have to fix or reinstall python itself.
argparse is (since Python 3.2) part of the standard library. Just get the file from the official github (I'm assuming cpython, adapt the version as necessary by selecting the correct branch, the link is for python 3.8) and put it back where the one you deleted was

Python2 - Unable to run pyinstaller

I installed pyinstaller using pip
pip install pyinstaller
but when I run it I get an error
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 7, in <module>
from PyInstaller.__main__ import run
File "/usr/local/lib/python2.7/dist-packages/PyInstaller/__init__.py", line 66, in <module>
__version__ = pkg_resources.get_distribution('PyInstaller').version
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 330, in get_distribution
if isinstance(dist,Requirement): dist = get_provider(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 209, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: PyInstaller
I cannot figure out what the issue is, I have tried reinstalling it. I have googled the error but no results come up that help.
Does anyone know a fix?

Installing PIL for anaconda python2.7

I can't figure out how to install PIL on my Mac (Sierra 10.12.4) running Anaconda (conda 4.3.18) python 2.7.10. Anaconda's default python is 3.5.2, so I'm installing with pip2.
My-MacBook-ProX:dymax thisuser$ sudo pip2 install PIL
Password:
Checking the installation location...
Getting information about 'PIL'...
2.0
Traceback (most recent call last):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/commands/install.py", line 44, in install
success = packaging.install.install(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 515, in install
info = get_infos(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 309, in get_infos
installed = list(get_distributions(use_egg_info=True))
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 440, in get_distributions
_generate_cache(use_egg_info, paths)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 103, in _generate_cache
for dist in _yield_distributions(gen_dist, gen_egg, paths):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 88, in _yield_distributions
yield Distribution(dist_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 146, in __init__
self.metadata = Metadata(path=metadata_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 219, in __init__
self.read(path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 323, in read
self.read_file(fp)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 330, in read_file
for field in _version2fieldlist(self['Metadata-Version']):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 95, in _version2fieldlist
raise MetadataUnrecognizedVersionError(version)
distutils2.errors.MetadataUnrecognizedVersionError: 2.0
Traceback (most recent call last):
File "/Users/thisuser/anaconda3/bin/pip2", line 11, in <module>
load_entry_point('pip2==0.0.1.dev1', 'console_scripts', 'pip2')()
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/__init__.py", line 19, in main
args.func(args)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/cli_wrapper.py", line 24, in install
result = pip2.commands.install.install(args.project_list)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/commands/install.py", line 44, in install
success = packaging.install.install(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 515, in install
info = get_infos(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 309, in get_infos
installed = list(get_distributions(use_egg_info=True))
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 440, in get_distributions
_generate_cache(use_egg_info, paths)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 103, in _generate_cache
for dist in _yield_distributions(gen_dist, gen_egg, paths):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 88, in _yield_distributions
yield Distribution(dist_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 146, in __init__
self.metadata = Metadata(path=metadata_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 219, in __init__
self.read(path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 323, in read
self.read_file(fp)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 330, in read_file
for field in _version2fieldlist(self['Metadata-Version']):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 95, in _version2fieldlist
raise MetadataUnrecognizedVersionError(version)
distutils2.errors.MetadataUnrecognizedVersionError: 2.0
I get identical error for sudo pip2 install pillow. I also tried with conda:
My-MacBook-ProX:dymax thisuser$ conda install pillow
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /Users/thisuser/anaconda3:
#
pillow 4.1.1 py35_0
In Python3 I can import PIL. Python2.7 I still get No module named PIL. Grateful for assistance. Is my pip/pip2 configured incorrectly?
Try by giving version
pip install pillow==6.1.0(latest)
If Doesn't work try
pip list
If not listed search location of python
which python
Search for site-packages folder inside resultant location of 'python' (usually under lib/python3.5/site-packages) and check if PIL present or not(packages are not installing right location)

TyperError installing jupyter

I'm trying to install jupyter on Ubuntu 14.04 LTS but I keep getting this error. I tried giving permissions to every folder and run the code as:
sudo -H pip3 install --user jupyter
But nothing worked. I also did the update on pip and it's running the latest version.
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.4/dist-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python3.4/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/root/.local/lib/python3.4/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/root/.local/lib/python3.4/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/root/.local/lib/python3.4/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/root/.local/lib/python3.4/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() missing 1 required positional argument: 'name'
Thanks for the help!
For me it works with the recent pyparsing package. Perhaps you need to upgrade your pyparsing to the recent version. If you installed it with apt-get, you need to remove the python3-pyparsing package, and install it with pip3.
sudo apt remove python3-pyparsing
sudo pip3 install pyparsing
As this answer writes, you need pyparsing>=2.0.2 to avoid this error.
I had this error as well, after a bit of digging I found this question that addresses the same error caused by some other software.
As the author states, the problem is that the call to MARKER_EXPR() should have a 'name' argument but it doesn't.
To fix this, edit line 59 of /usr/local/lib/python3.4/dist-packages/packaging/requirements.py and just add quotes to the call to MARKER_EXPR() like so:
MARKER_EXPR = originalTextFor(MARKER_EXPR(""))("marker")

Categories