简体   繁体   English

如何在 Linux Ubuntu 16.04 中使用 Pip3 为 Python 3.6 安装模块?

[英]How do I install modules for Python 3.6 using Pip3 in Linux Ubuntu 16.04?

I am running Linux Ubuntu 16.04, and my default version of python3 is Python 3.5.2.我正在运行 Linux Ubuntu 16.04,我的默认 python3 版本是 Python 3.5.2。

I downloaded Python 3.6 to have a more recent version of Python.我下载了 Python 3.6 以获得更新版本的 Python。 I can get it running on my command line using 'python3.6', while my default version of python3 remains Python 3.5.2.我可以使用“python3.6”在我的命令行上运行它,而我的默认 python3 版本仍然是 Python 3.5.2。

I want to install the packages I had on Python 3.5.2 in Python 3.6.我想在 Python 3.6 中安装我在 Python 3.5.2 上的软件包。 I tried to use the following command:我尝试使用以下命令:

pip3 install numpy

But I get the following message:但我收到以下消息:

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in ./.local/lib/python3.5/site-packages (1.18.5)

How do I get pip3 to install packages to Python 3.6 specifically?如何让 pip3 专门将软件包安装到 Python 3.6?

This is my current version of pip3:这是我当前的 pip3 版本:

pip3 --version
pip 20.2.4 from /home/[username]/.local/lib/python3.5/site-packages/pip (python 3.5)

您必须使用精确版本,例如pip-3.5.2pip-3.6

You can try pip3.6 or python3.6 -m pip .您可以尝试pip3.6python3.6 -m pip

If both don't work, pip is not installed for the new Python version.如果两者都不起作用,则不会为新的 Python 版本安装pip Follow the instructions at https://pip.pypa.io/en/stable/installing/ but make sure to use python3.6 instead of just python !按照https://pip.pypa.io/en/stable/installing/ 上的说明进行操作,但请确保使用python3.6而不仅仅是python

On some installations it might be necessary to use sudo before python / python3.6 .在某些安装中,可能需要在python / python3.6之前使用sudo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM