简体   繁体   English

Pip安装到python3.6但是我在Ubuntu 18.04上使用带有VS Code的python3.7

[英]Pip is installed to python3.6 but I'm using python3.7 with VS Code on Ubuntu 18.04

I am new to python and ubuntu to be fair. 我是python和ubuntu的新手要公平。 I have been recently following a couple of tutorials and they use pylint to check the syntax of the python code. 我最近一直在关注几个教程,他们使用pylint来检查python代码的语法。

I've installed it as normal through the terminal using 'sudo pip3 install pylint', however whenever I format in VS Code I get an error stating pylint does not exist, do I want to install. 我通过终端使用'sudo pip3 install pylint'正常安装它,但是每当我在VS Code中格式化时出现错误,说明pylint不存在,我是否要安装。 On the attempt to install, i get another error due to pip not existing. 在尝试安装时,由于pip不存在,我得到另一个错误。

I've looked in the terminal after attempting to reinstall pip and pylint, however it's going to the python3.6 folder and not python3.7 folder, hence the errors. 在尝试重新安装pip和pylint之后,我已经查看了终端,但是它将进入python3.6文件夹而不是python3.7文件夹,因此出现错误。

Any ideas on how to resolve this? 关于如何解决这个问题的任何想法?

Pip output is currently: "pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)" Pip输出目前是:“来自/ usr / lib / python3 / dist-packages(python 3.6)的pip 9.0.1”

If i try to install pylint via the terminal using "python3 -m pip install pylint", I get the output error of: "/usr/local/bin/python3: No module named pip" 如果我尝试使用“python3 -m pip install pylint”通过终端安装pylint,我得到输出错误:“/ usr / local / bin / python3:没有名为pip的模块”

After following stovfl's suggestions i realised that python 3 needed redirecting to the 3.7 install 按照stovfl的建议后,我意识到python 3需要重定向到3.7安装

I googled and found this article: http://ubuntuhandbook.org/index.php/2017/07/install-python-3-6-1-in-ubuntu-16-04-lts/ 我用谷歌搜索了这篇文章: http//ubuntuhandbook.org/index.php/2017/07/install-python-3-6-1-in-ubuntu-16-04-lts/

At step 3, it tells you how to make python3 use the new install with the following command: 在第3步,它告诉您如何使用以下命令使python3使用新安装:

sudo update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.7 1

Now when I intall pip and pylint it directs to the new 3.7 folder. 现在,当我输入pip和pylint时,它会指向新的3.7文件夹。 Meaning it also works as intended with VS Code. 这意味着它也适用于VS Code。

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

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