Pip installation is failing on Mac - macos

"sudo easy_install pip" fails with the following error:
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 11, in <module>
load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')()
File "/Users/swastika.singhal/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 572, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Users/swastika.singhal/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
return ep.load()
File "/Users/swastika.singhal/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2408, in load
return self.resolve()
File "/Users/swastika.singhal/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2414, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 46, in <module>
from setuptools.archive_util import unpack_archive
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/archive_util.py", line 15, in <module>
from pkg_resources import ensure_directory, ContextualZipFile
ImportError: cannot import name ContextualZipFile
The Google solutions did not work for me so far.

This GitHub issue helped me fix it: github.com/PyMySQL/mysqlclient-python/issues/169
Specifically:
There are lines in mysql_config like following:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
I edited them to:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"

Related

the computer can't import pip and install things with it

I tried to download python libraries using pip install like pygame, pytube... but it just won't work and give me the following error message:
Traceback (most recent call last):
File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python39\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\requests\__init__.py", line 43, in <module>
from pip._vendor import urllib3
ImportError: cannot import name 'urllib3' from 'pip._vendor' (C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\__init__.py)
I wrote the import statement in python: from pip._vendor import urllib3 and I got the same error, it the pc can't import it
how can I fix that, if I can't, can I just download libraries from the browser?
Try using:
python -m pip install pytube

fragile console script: pkg_resources.DistributionNotFound

If I create console_scripts via entry_point in setup.py, then this file gets created:
#!/home/myproject_cok_d/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'mylib','console_scripts','do-magic'
__requires__ = 'mylib'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('mylib', 'console_scripts', 'do-magic')()
)
Unfortunately this script is fragile.
Sometimes I get exceptions like this:
Traceback (most recent call last):
File ".../bin/do-magic", line 6, in <module>
from pkg_resources import load_entry_point
File ".../local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2999, in <module>
#_call_aside
File ".../local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2985, in _call_aside
f(*args, **kwargs)
File ".../local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3012, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File ".../local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 662, in _build_master
ws.require(__requires__)
File ".../local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 970, in require
needed = self.resolve(parse_requirements(requirements))
File ".../local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 856, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'PyPDF2==1.26' distribution was not found and is required by mylib
Is there a way to make my script (do-magic) more mature?
In this case: It does not need PyPDF2.
I ran into the same error. To solve this issue, you must update PYTHONPATH to add the site directory. On Windows you would go to your the command prompt and type this:
set pythonpath=<PATH_TO_SITE_DIR>
And Mac is this:
export PYTHONPATH="${PYTHONPATH}:<PATH_TO_SITE_DIR>"
Here is more information about the error.

OS X pip3 broken with brew install python3.6.5_1

I just did a fresh install of python3 (3.6.5_1) on Mac OS (High Sierra) and pip3 does not work. I get the following error with pip3:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python3.6/site-packages/pip/_internal/index.py", line 39, in <module>
from pip._internal.wheel import Wheel, wheel_ext
File "/usr/local/lib/python3.6/site-packages/pip/_internal/wheel.py", line 7, in <module>
import compileall
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/compileall.py", line 20, in <module>
from concurrent.futures import ProcessPoolExecutor
File "/Library/Python/2.7/site-packages/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/Library/Python/2.7/site-packages/concurrent/futures/_base.py", line 357
raise type(self._exception), self._exception, self._traceback
^
SyntaxError: invalid syntax
which pip3 returns /usr/local/bin/pip3
I have searched and can't find a solution.

Cannot install pylint on Windows 7 x64, Python 2.7, pip error

I'm trying to install pylint with pip install pylint
But i've got this at the end of installation:
Removing temporary dir c:\users\fixxxer\appdata\local\temp\pip_build_Fixxxer...
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "C:\Python27\lib\site-packages\pip\req.py", line 292, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
File "C:\Python27\lib\site-packages\pip\req.py", line 265, in setup_py
import setuptools
File "C:\Python27\lib\site-packages\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Python27\lib\site-packages\setuptools\extension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "C:\Python27\lib\site-packages\setuptools\dist.py", line 16, in <module>
from setuptools.depends import Require
File "C:\Python27\lib\site-packages\setuptools\depends.py", line 6, in <module>
from setuptools import compat
File "C:\Python27\lib\site-packages\setuptools\compat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 204, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
Any ideas how can i fix this or some workarounds?
How can i install it manually?
UPDATE.
replacing
default_encoding = sys.getdefaultencoding()
with
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()
does this:
Cleaning up...
Removing temporary dir c:\users\fixxxer\appdata\local\temp\pip_build_Fixxxer...
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "C:\Python27\lib\site-packages\pip\req.py", line 292, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
File "C:\Python27\lib\site-packages\pip\req.py", line 265, in setup_py
import setuptools
File "C:\Python27\lib\site-packages\setuptools\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "C:\Python27\lib\site-packages\setuptools\extension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "C:\Python27\lib\site-packages\setuptools\dist.py", line 16, in <module>
from setuptools.depends import Require
File "C:\Python27\lib\site-packages\setuptools\depends.py", line 6, in <module>
from setuptools import compat
File "C:\Python27\lib\site-packages\setuptools\compat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 204, in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 359, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 263, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 4-5: illegal multibyte sequence
Found a problem.
There was a few MIME types with Cyrillic names in
HKEY_CLASSES_ROOT\MIME\Database\Content Type
Removed them and problem was solved.
I had the same error and this helped me https://stackoverflow.com/a/23278373/2571607
Basically, open C:\Python27\Lib\mimetypes.py
replace
‘default_encoding = sys.getdefaultencoding()’
with
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()

Fresh installation of sphinx-quickstart fails

Trying to get it going with Sphinx for the first time, with a clean Sphinx 1.1.3 installation, and shinx-quickstart fails. Should there be any dependencies installed? I tried to pip --force-reinstall sphinx but the result is the same.
myhost:doc anton$ sphinx-quickstart
Traceback (most recent call last):
File "/usr/local/bin/sphinx-quickstart", line 8, in <module>
load_entry_point('Sphinx==1.1.3', 'console_scripts', 'sphinx-quickstart')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 318, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2221, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1954, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.7/site-packages/Sphinx-1.1.3-py2.7.egg/sphinx/quickstart.py", line 19, in <module>
from sphinx.util.osutil import make_filename
File "/Library/Python/2.7/site-packages/Sphinx-1.1.3-py2.7.egg/sphinx/util/__init__.py", line 25, in <module>
from docutils.utils import relative_path
File "/Library/Python/2.7/site-packages/docutils-0.9-py2.7.egg/docutils/utils/__init__.py", line 19, in <module>
from docutils.io import FileOutput
File "/Library/Python/2.7/site-packages/docutils-0.9-py2.7.egg/docutils/io.py", line 18, in <module>
from docutils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/Library/Python/2.7/site-packages/docutils-0.9-py2.7.egg/docutils/error_reporting.py", line 47, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
I was getting the same issue in Mac OS X Snow Leopard. It seems to be an issue with Terminal.app.
Please add the following to your $HOME/.bash_profile
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Do
source $HOME/.bash_profile
and try. This will solve the issue.

Resources