2017-12-12 4 views
0

私は/python/に複数のpython 3をインストールしたUbuntu 16.04マシンを持っており、それらを自由に切り替えることができる必要があります。これらのバージョンの1つはPython 3.3で、pipはPython 3.4.xまでプリインストールされていませんでしたので、このpythonインストールにpipをインストールします。非標準パスにあるPython 3.3インストールでpip3を正しくインストールするにはどうすればよいですか?

get-pip.py試行を/usr/binでPIPのバージョンをアンインストールする:

それは実際に、私はトラブルこの管理を抱えている/パイソン/ python33インストールに統合する必要があるため、私は、ディストリビューションのパッケージを使用する必要はありません私は --ignore-installedを追加する場合
$ /tmp/get-pip.py --prefix /python/python33 
Collecting pip 
    Using cached pip-9.0.1-py2.py3-none-any.whl 
Installing collected packages: pip 
    Found existing installation: pip 8.1.2 
    Uninstalling pip-8.1.2: 
Exception: 
Traceback (most recent call last): 
    File "/tmp/tmpdgdWPZ/pip.zip/pip/basecommand.py", line 215, in main 
    status = self.run(options, args) 
    File "/tmp/tmpdgdWPZ/pip.zip/pip/commands/install.py", line 342, in run 
    prefix=options.prefix_path, 
    File "/tmp/tmpdgdWPZ/pip.zip/pip/req/req_set.py", line 778, in install 
    requirement.uninstall(auto_confirm=True) 
    File "/tmp/tmpdgdWPZ/pip.zip/pip/req/req_install.py", line 754, in uninstall 
    paths_to_remove.remove(auto_confirm) 
    File "/tmp/tmpdgdWPZ/pip.zip/pip/req/req_uninstall.py", line 115, in remove 
    renames(path, new_path) 
    File "/tmp/tmpdgdWPZ/pip.zip/pip/utils/__init__.py", line 267, in renames 
    shutil.move(old, new) 
    File "/usr/lib/python2.7/shutil.py", line 303, in move 
    os.unlink(src) 
OSError: [Errno 13] Permission denied: '/usr/bin/pip' 
You are using pip version 8.1.2, however version 9.0.1 is available. 
You should consider upgrading via the 'pip install --upgrade pip' command. 

は、それが出てエラーはありませんが、それでも、PIPのバージョンを見ているの/ usr/binに(それが不満だという古い8.1.2 1)で:

$ /tmp/get-pip.py --ignore-installed --prefix /python/python33 
Collecting pip 
    Using cached pip-9.0.1-py2.py3-none-any.whl 
Installing collected packages: pip 
Successfully installed pip-9.0.1 
You are using pip version 8.1.2, however version 9.0.1 is available. 
You should consider upgrading via the 'pip install --upgrade pip' command. 

easy_installはどちらか動作しません:

$ export PYTHONPATH="$PYTHONPATH:/python/python33/"; /usr/bin/easy_install --prefix /python/python33 pip 
TEST FAILED: /python/python33/lib/python2.7/site-packages does NOT support .pth files 
error: bad install directory or PYTHONPATH 

You are attempting to install a package to a directory that is not 
on PYTHONPATH and which Python does not read ".pth" files from. The 
installation directory you specified (via --install-dir, --prefix, or 
the distutils default setting) was: 

    /python/python33/lib/python2.7/site-packages 

and your PYTHONPATH environment variable currently contains: 

    '/pyqt/sip-4.13.1/site-packages:/pyqt/site-packages:/python/python33/' 

Here are some of your options for correcting the problem: 

* You can choose a different installation directory, i.e., one that is 
    on PYTHONPATH or supports .pth files 

* You can add the installation directory to the PYTHONPATH environment 
    variable. (It must then also be on PYTHONPATH whenever you run 
    Python and want to use the package(s) you are installing.) 

* You can set up the installation directory to support ".pth" files by 
    using one of the approaches described here: 

    https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations 

Please make the appropriate changes for your system and try again. 

そして、なぜそれが/python/python33/lib/python2.7/site-packagesにインストールしようとしていますか?これはpipや何かのpython 2バージョンですか?

私はここで多くの関連する回答を読んだことがありますが、これまでのところ誰も助けてくれませんでした。

+0

複数のバージョンのPythonを使用する場合は、virtualenvなどのcondaなどの類似のものを使用する必要があります。 – chrisz

+0

間違いなく。しかし、何らかの理由でそれを想像してみましょう。私が企業環境にいるとしたら... – iLikeDirt

+1

'/ python/python33/tmp/get-pip.py'を試してみましたか? – georgexsh

答えて

0

16.04 Ubuntu BoxにPython 3.5.2 3.6.3がインストールされています。

3.5.2は

3.6.3が/ usr/local/bin python3.6点に設置され、このバージョンへのpython3とpython3.5点については/ usr/binに シンボリックリンクでシステムにインストールされたバージョンでありますこのバージョンの私にとって

次作品へ:

wget https://bootstrap.pypa.io/get-pip.py 
python3.6 get-pip.py 
mkdir /home/ubuntu/myproj/venv 
python3.6 -m venv /home/ubuntu/myproj/venv 
#Activate the venv 
source /home/ubuntu/myproj/venv/bin/activate 

のpython3今、私の仮想環境内で3.6を指しています。

16.04にどのようにしてPython 3.6をインストールしましたか?私は物事を壊さないように傷つける世界を持っていました。私はソースから構築しました。詳細はgistを参照してください。このquestionは理由を説明しています。そしてこのblogポストは私に解決策を与えました。

+0

[このppa](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa)を試してみましたか? – georgexsh

+0

はい、それはpython 3.6で問題なく動作します。問題は、apt-getがシステムレベルで動作するように、16.04にpython 3.5が必要なことです。 – WombatPM

+0

deadsnake ppaからpython36をインストールすると 'shadow system pyhtonはありません。問題がありますか? – georgexsh

関連する問題