【问题标题】:how to install turtle with python3 on linux如何在linux上用python3安装turtle
【发布时间】:2017-02-15 18:01:12
【问题描述】:

当我安装turtle时,遇到这样的问题:

我的 python 版本是 3.5.2,操作系统是 Ubuntu 16.04 LTS

【问题讨论】:

  • 你试过import turtle吗?据我所知turtle 应该已经与 Python3 一起安装,您不必安装它。据我所知,Ubuntu 16 删除了 turtle 可能使用的 tkinter 模块,因此您必须安装 python-tk

标签: python-3.5


【解决方案1】:
apt install python3-tk

它已经过测试并且可以在 Linux Mint 和 Ubuntu 上完美运行...
编辑:
原因是因为turtle是基于tkinter的,例如:

【讨论】:

    【解决方案2】:

    我假设您要求Turtle 绘制forwardleft 等。

    它已经与 Python 一起安装。您不必安装它。可能您可能必须使用pip3 install python3-tkapt install python3-tk 安装python3-tk


    pip search turtle
    

    部分结果

    turtle (0.0.2) - Turtle is an HTTP proxy whose purpose is to throttle connections to
                     specific hostnames to avoid breaking terms of usage of those API
                     providers (like del.icio.us, technorati and so on).
    

    你尝试安装一些HTTP proxy

    except ValueError, ve: 在 Python 2 中是正确的语法,但在 Python 3 中却不是。

    【讨论】:

    • pip install python3-tk 失败:“下载/解包 python3-tk 找不到任何满足要求的下载 python3-tk 清理...没有找到 python3-tk 的发行版存储调试在 /home/follinge/.pip/pip.log 中记录失败
    • @FrederickOllinger 阅读我的答案 - python3-tk 不是 python 模块,而是 linux 模块,您必须使用 apt(在 Ubuntu/Mint 上)或类似工具来安装它。顺便提一句。应该预先安装在 python3-tk 上,您可以使用import tkinter 在 python 中检查它
    • 它也已经与 Python3 捆绑在一起了。我的操作系统是 Debian 测试(书虫)。
    【解决方案3】:

    我使用的是 Ubuntu 18.10,最近在将 Python 3 配置为我的默认环境后,我遇到了同样的错误。 我用这个命令重新配置它,它工作了。

    sudo apt install python3-tk
    

    成功!!

    【讨论】:

      【解决方案4】:
      pip install python-tk
      

      然后转到 python shell 并输入

      from turtle import*
      fd(100)
      

      【讨论】:

        【解决方案5】:

        我遇到了同样的错误,但在 Mac 操作系统上,我尝试通过 brew 更新我的 python。这解决了我的问题。 首先,授予 brew 访问您共享文件的权限,

        sudo chown -R $(whoiam) /usr/local/share
        
        

        这是 brew :D 的另一个问题,您可以测试下一个命令并仅在需要时使用它。 最后,

        brew upgrade python3
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-03-22
          • 2017-06-16
          • 2016-03-20
          • 2019-08-03
          • 2018-01-23
          相关资源
          最近更新 更多