Cant install pip on mac? Using VS code - python

whenever i use the terminal and type pip3 install requests this is what happens:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3", line 11, in <module>
sys.exit(main())
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/__init__.py", line 13, in main
from pip._internal.utils.entrypoints import _wrapper
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/utils/entrypoints.py", line 4, in <module>
from pip._internal.cli.main import main
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/configuration.py", line 21, in <module>
from pip._internal.exceptions import (
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_internal/exceptions.py", line 8, in <module>
from pip._vendor.requests.models import Request, Response
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/__init__.py", line 123, in <module>
from . import utils
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/utils.py", line 27, in <module>
from ._internal_utils import to_native_string
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str, str
File "/Users/hawawague/Library/Python/3.7/lib/python/site-packages/pip/_vendor/requests/compat.py", line 63, in <module>
from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment
ImportError: cannot import name 'parse_http_list' from 'urllib.request' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py)
Is there something I did wrong?

Try running pip3 install --upgrade pip
then try again with pip3 install requests

Related

"ImportError: dynamic module does not define module export function (PyInit__socket)" when using pip in a new conda envrionment

when I try to start a new conda environment using
conda create --name myenv
and then
conda install -n myenv pip
and then I try use
pip
I get the following error message:
Traceback (most recent call last):
File "C:\Users\ese\Miniconda3\envs\myenv\Scripts\pip-script.py", line 6, in <module>
from pip._internal.cli.main import main
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 24, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\requests\__init__.py", line 43, in <module>
from pip._vendor import urllib3
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 11, in <module>
from . import exceptions
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\urllib3\exceptions.py", line 3, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 234, in create_module
return self.load_module(spec.name)
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 209, in load_module
mod = mod._resolve()
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 118, in _resolve
return _import_module(self.mod)
File "C:\Users\ese\Miniconda3\envs\myenv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 87, in _import_module
__import__(name)
File "C:\Users\ese\Miniconda3\envs\myenv\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\ese\Miniconda3\envs\myenv\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\ese\Miniconda3\envs\myenv\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\ese\Miniconda3\envs\myenv\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\ese\Miniconda3\envs\myenv\lib\email\utils.py", line 29, in <module>
import socket
File "C:\Users\ese\Miniconda3\envs\myenv\lib\socket.py", line 51, in <module>
import _socket
ImportError: dynamic module does not define module export function (PyInit__socket)
I have tried reinstalling conda in my different versions and it keeps happening. I am actually having a feeling this might be related to having some weird restrictions on my company PC, but I am unsure. Anyone know how I could solve this? Thanks!

Using virtualenv in VSCode gives ImportError: cannot import name 'appdirs' but normal terminal does not

When using virtualenv in VSCode integrated terminal I get the following error when trying to use pip or pip3
Traceback (most recent call last):
File "/home/me/repo/py-hello/venv/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
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 25, in <module>
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 19, in <module>
from pip._internal.utils import appdirs
File "/usr/lib/python3/dist-packages/pip/_internal/utils/appdirs.py", line 13, in <module>
from pip._vendor import appdirs as _appdirs
ImportError: cannot import name 'appdirs' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)
However, this isn't the case when using a regular terminal. I can run pip fine.
I found a few mentions in other posts here and here but neither are helping me.

Python ImportError: cannot import name HeaderParsingError when running pip upgrade in virtualenv

Inside the python virtual environment I am unable to install anything via pip.
This is the command I run:
pip install --upgrade pip
The error output:
ImportError: cannot import name HeaderParsingError
The whole traceback is as shown below:
(env)root#ali-Lenovo-G50-80:/home/ali# pip install --upgrade pip
Traceback (most recent call last):
File "/home/ali/env/bin/pip", line 7, in <module>
from pip import main
File "/home/ali/env/local/lib/python2.7/site-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/home/ali/env/local/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/home/ali/env/local/lib/python2.7/site-packages/pip/download.py", line 22, in <module>
from pip._vendor import requests, six
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 58, in <module>
from . import utils
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 33, in <module>
from .connection import (
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/connection.py", line 41, in <module>
from .util import (
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/__init__.py", line 5, in <module>
from .response import is_fp_closed
File "/home/ali/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/response.py", line 4, in <module>
from ..exceptions import HeaderParsingError
ImportError: cannot import name HeaderParsingError
Any help please?

Getting a python error when running the EB command

I installed ec2 api tools and when I run the command I get this error:
Traceback (most recent call last):
File "/usr/local/bin/eb", line 9, in <module>
load_entry_point('awsebcli==3.9.0', 'console_scripts', 'eb')()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2381, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/distribute-0.6.49-py2.7.egg/pkg_resources.py", line 2087, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.7/site-packages/ebcli/core/ebcore.py", line 42, in <module>
from . import ebglobals, base, io, hooks
File "/Library/Python/2.7/site-packages/ebcli/core/hooks.py", line 21, in <module>
from ..lib import aws
File "/Library/Python/2.7/site-packages/ebcli/lib/aws.py", line 21, in <module>
import botocore.session
File "/Library/Python/2.7/site-packages/botocore/session.py", line 26, in <module>
import botocore.credentials
File "/Library/Python/2.7/site-packages/botocore/credentials.py", line 22, in <module>
from dateutil.parser import parse
File "/Library/Python/2.7/site-packages/dateutil/parser.py", line 43, in <module>
from . import tz
File "/Library/Python/2.7/site-packages/dateutil/tz/__init__.py", line 1, in <module>
from .tz import *
File "/Library/Python/2.7/site-packages/dateutil/tz/tz.py", line 23, in <module>
from ._common import tzname_in_python2, _tzinfo, _total_seconds
File "/Library/Python/2.7/site-packages/dateutil/tz/_common.py", line 2, in <module>
from six.moves import _thread
ImportError: cannot import name _thread
I installed it using:
sudo pip install --upgrade awsebcli

In using flask with soundcloud library , Why 'no module named moves'?

Trying to make use of the python-soundcloud package, imported it to implement its server side authentication for my app:
$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from mic import app, db
File "/Users/harryagbo/Documents/Portfolio/Mojok/mic.py", line 3, in <module>
import soundcloud
File "/usr/local/lib/python2.7/site-packages/soundcloud/__init__.py", line 8, in <module>
from soundcloud.client import Client
File "/usr/local/lib/python2.7/site-packages/soundcloud/client.py", line 8, in <module>
from soundcloud.request import make_request
File "/usr/local/lib/python2.7/site-packages/soundcloud/request.py", line 6, in <module>
import requests
File "/usr/local/lib/python2.7/site-packages/requests/__init__.py", line 52, in <module>
from . import utils
File "/usr/local/lib/python2.7/site-packages/requests/utils.py", line 22, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python2.7/site-packages/requests/compat.py", line 95, in <module>
from .packages import chardet
File "/usr/local/lib/python2.7/site-packages/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 44, in <module>
from .util import get_host, is_connection_dropped
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/__init__.py", line 5, in <module>
from .response import is_fp_closed
File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/response.py", line 2, in <module>
from ..packages.six.moves import http_client as httplib
ImportError: No module named moves

Categories

Resources