Exception: Traceback (most recent call last): File "\usr\lib\python3.6\dist-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "\usr\lib\python3.6\dist-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "\usr\lib\python3.6\dist-packages\pip\req\req_set.py", line 784, in install **kwargs File "\usr\lib\python3.6\dist-packages\pip\req\req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "\usr\lib\python3.6\dist-packages\pip\req\req_install.py", line 1064, in move_wheel_files isolated=self.isolated, File "\usr\lib\python3.6\dist-packages\pip\wheel.py", line 345, in move_wheel_files clobber(source, lib_dir, True) File "\usr\lib\python3.6\dist-packages\pip\wheel.py", line 316, in clobber ensure_dir(destdir) File "\usr\lib\python3.6\dist-packages\pip\utils\__init__.py", line 83, in ensure_dir os.makedirs(path) File "\usr\lib64\python3.6\os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '\usr\lib\python3.6\dist-packages\urllib3' You are using pip version 9.0.3, however version 19.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip'command.
ec2-user:~ $ pip Traceback (most recent call last): File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 658, in _build_master ws.require(__requires__) File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 972, in require needed = self.resolve(parse_requirements(requirements)) File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 863, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.VersionConflict: (pip 19.3.1 (\usr\local\lib\python3.6\site-packages), Requirement.parse('pip==9.0.3'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "\usr\bin\pip", line 6, in <module> from pkg_resources import load_entry_point File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 3049, in <module> @_call_aside File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 3033, in _call_aside f(*args, **kwargs) File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 3062, in _initialize_master_working_set working_set = WorkingSet._build_master() File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 660, in _build_master return cls._build_from_requirements(__requires__) File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 673, in _build_from_requirements dists = ws.resolve(reqs, Environment()) File "\usr\lib\python3.6\dist-packages\pkg_resources\__init__.py", line 858, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'pip==9.0.3' distribution was not found and is required by the application
whichコマンドにallオプションをつけてpipの場所を探します。
1 2 3
ec2-user:~ $ which -a pip \usr\local\bin\pip \usr\bin\pip
ec2-user:~ $ python -m pip install tweepy --user Collecting tweepy Using cached https:\\files.pythonhosted.org\packages\36\1b\2bd38043d22ade352fc3d3902cf30ce0e2f4bf285be3b304a2782a767aec\tweepy-3.8.0-py2.py3-none-any.whl Requirement already satisfied: six>=1.10.0 in \usr\local\lib\python3.6\site-packages (from tweepy) (1.13.0) Collecting requests>=2.11.1 Using cached https:\\files.pythonhosted.org\packages\51\bd\23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb\requests-2.22.0-py2.py3-none-any.whl Collecting PySocks>=1.5.7 Using cached https:\\files.pythonhosted.org\packages\8d\59\b4572118e098ac8e46e399a1dd0f2d85403ce8bbaad9ec79373ed6badaf9\PySocks-1.7.1-py3-none-any.whl Collecting requests-oauthlib>=0.7.0 Using cached https:\\files.pythonhosted.org\packages\a3\12\b92740d845ab62ea4edf04d2f4164d82532b5a0b03836d4d4e71c6f3d379\requests_oauthlib-1.3.0-py2.py3-none-any.whl Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 Using cached https:\\files.pythonhosted.org\packages\b4\40\a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539\urllib3-1.25.7-py2.py3-none-any.whl Collecting idna<2.9,>=2.5 Using cached https:\\files.pythonhosted.org\packages\14\2c\cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9\idna-2.8-py2.py3-none-any.whl Collecting certifi>=2017.4.17 Using cached https:\\files.pythonhosted.org\packages\b9\63\df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99\certifi-2019.11.28-py2.py3-none-any.whl Collecting chardet<3.1.0,>=3.0.2 Using cached https:\\files.pythonhosted.org\packages\bc\a9\01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8\chardet-3.0.4-py2.py3-none-any.whl Collecting oauthlib>=3.0.0 Using cached https:\\files.pythonhosted.org\packages\05\57\ce2e7a8fa7c0afb54a0581b14a65b56e62b5759dbc98e80627142b8a3704\oauthlib-3.1.0-py2.py3-none-any.whl Installing collected packages: urllib3, idna, certifi, chardet, requests, PySocks, oauthlib, requests-oauthlib, tweepy Successfully installed PySocks-1.7.1 certifi-2019.11.28 chardet-3.0.4 idna-2.8 oauthlib-3.1.0 requests-2.22.0 requests-oauthlib-1.3.0 tweepy-3.8.0 urllib3-1.25.7
ちゃんとインストールされているか確認します。
インタプリタモードで確認します。
1 2 3 4 5
ec2-user:~ $ python Python 3.6.8 (default, Oct 14 2019, 21:22:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux Type "help", "copyright", "credits" or "license"for more information. >>> import tweepy