Python3にpipを接続する方法

Python3にpipを接続する方法

私はDebian GNU / Linux 7.11(gasp)を使用しており、デフォルトのPythonは2.7.3、pipは1.1です(9.xに更新しました)。いくつかのスクリプトを実行するためにPython 3.6をインストールしましたが、このエラーが発生しました。

Traceback (most recent call last):
  File "place_fixed2_debugged.py", line 2, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

それで試してみましたが、インストールされていることがわかりpip install requestsました。その後、リクエストモジュールを手動でインストールしようとしました。 Request-2.18.4をダウンロードして実行しましたが、python3 setup.pyこのエラーが発生しました。

File "setup.py", line 9, in <module>
    from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'

apt-get install python3-setuptoolsその後、python3-setuptoolsもインストールされていることを示しました。

ここでの問題は、pipとaptがデフォルトのpython2.7に接続されているパスの下にすべてのPython関連パッケージをインストールし、リクエストモジュールまたはsetuptoolがpython3に接続されていないことです。

zlibモジュールが必要なvirtualenvを試してみましたpip install zlib

root@localhost:~/Python-3.6.0# pip install zlib
Collecting zlib
/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Could not find a version that satisfies the requirement zlib (from versions: )
No matching distribution found for zlib

pipをpython3.6に接続するより管理しやすい他の方法はありますか?私は本当にvirtualenvを設定したくありません。ありがとうございます!

ベストアンサー1

あなたは走らなければなりませんsudo apt install pip3

おすすめ記事