简体   繁体   English

我已经安装了 python-3.9.1 和 pip 但是在运行命令 python3 -V 得到结果为 python 3.6.9 如何获得 python 版本 3。

[英]I've installed python-3.9.1 and pip but while running the command python3 -V got the result as python 3.6.9 how do I get python version 3.9

sudo apt-get install python3.7 sudo apt-get install python3.7

Reading package lists... Done读取 package 列表...完成

Building dependency tree构建依赖树

Reading state information... Done读取 state 信息...完成

python3.7 is already the newest version (3.7.10-1+bionic2). python3.7 已经是最新版本(3.7.10-1+bionic2)。

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 0 升级,0 新安装,0 删除,0 未升级。

N: Ignoring file 'security' in directory '/etc/apt/sources.list.d/' as it has no filename extension root@ubuntu:~# python3 -V Python 3.6.9 N:忽略目录“/etc/apt/sources.list.d/”中的文件“security”,因为它没有文件扩展名 root@ubuntu:~# python3 -V Python 3.6.9

I presume you are a Linux user.我假设您是 Linux 用户。 I faced a similar issue when I was trying to install Python 3.9 but when I ran python -V in the terminal, it would tell me I had version 2. I can't guarantee我在尝试安装 Python 3.9 时遇到了类似的问题,但是当我在终端中运行 python -V 时,它会告诉我我有版本 2。我不能保证

this will work but it worked for me.这会起作用,但它对我有用。 If you are using Ubuntu 20.04 a Linux distro, by default you have Python 3.9.如果您使用 Ubuntu 20.04 和 Linux 发行版,默认情况下您拥有 Python 3.9。 In Ubuntu 18 and 16 there is also a Python version pre-installed.在 Ubuntu 18 和 16 中,还预装了 Python 版本。 In your case, you need to first uninstall Python 3. Using this command in the terminal.在您的情况下,您需要先卸载 Python 3. 在终端中使用此命令。

sudo apt-get remove --purge python3

After uninstalling, reinstall as Python 3.9 version using this command:卸载后,使用以下命令重新安装为 Python 3.9 版本:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9
python3.9 --version

Again if you're using an editor like Pycharm your base interpreter will be messed up.同样,如果您使用 Pycharm 之类的编辑器,您的基本解释器将被搞砸。 So please be careful when uninstalling.所以卸载的时候要小心。 And this code works on Ubuntu which I presume is what you are working on.此代码适用于 Ubuntu,我认为这就是您正在处理的。 Another thing you need to install a repository to get Py 3.9.您需要安装存储库以获取 Py 3.9 的另一件事。 it's called deadsnakes I've mentioned the code above on how you could install it.它被称为 deadsnakes 我在上面提到了如何安装它的代码。 I hope you faced no issues.我希望你没有遇到任何问题。 Remember it worked for me but I'm not sure it will work for you.记住它对我有用,但我不确定它是否对你有用。 Enjoy with Python 3.9 if the installation is successful:)如果安装成功,请享受 Python 3.9 :)

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

相关问题 pip install regex 无法在 Anaconda python3.6.9 virtualenv 上构建 - pip install regex Fails to build on Anaconda python3.6.9 virtualenv 在Windows上编译Python 3.6.9 - Compiling Python 3.6.9 on Windows 使用 Python 3.6.9 导入 smtplib 时如何解决错误? - How to resolve the error while importing smtplib using Python 3.6.9? 在 Python 3.6.9 中以纳秒为单位获取纪元时间戳 - Get Epoch Timestamp in Nanoseconds in Python 3.6.9 我已经安装了 python 3.6,但是在检查版本时 ubuntu 仍然提供 python 2.7。 我如何切换到 3.6? - I have installed python 3.6 but ubuntu still gives python 2.7 when checked for the version. How do I switch to 3.6? 如何设置cron以专门与python3一起运行? - How do I setup a cron to run specifically with python3? 在 Jupyter Notebook 上编写代码时如何解决 Python3 中的 FileNotFound 错误? - How do I solve the FileNotFound error in Python3 while writing code on Jupyter Notebook? 如何在不同版本的python上安装python模块 - How do I install a python module on a different version of python python3 - 从异步方法获得结果 - python3 -Get result from async method 安装了 Python3,但为什么我不能在终端中运行 python 文件 - Python3 installed, but why can't I run python file in terminal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM