首页 新闻 会员 周边

如何在termux上安装Python的turtle库?

0
悬赏园豆:50 [已解决问题] 解决于 2020-02-27 12:27

我是初学Python的,想请教一下,如何在termux上安装turtle?谢谢!

老菜苗的主页 老菜苗 | 初学一级 | 园豆:161
提问于:2020-02-23 07:52
< >
分享
最佳答案
0

升级pip:pip install --upgrade pip 升级 setuptools:pip install --upgrade setuptools,执行完再试试,如果还是不行参考下这几篇文章https://oomake.com/question/178949,https://blog.csdn.net/qq_34272008/article/details/87395093

收获园豆:50
风行天下12 | 老鸟四级 |园豆:3867 | 2020-02-23 12:55

①升级pip,输入“pip install --upgrade pip”后,显示如下:
$ pip install --upgrade pip
Requirement already up-to-date: pip in /data/data/com.termux/files/usr/lib/python3.8/site-packages (20.0.2)
我理解为,“已经升级到最新版本。”
②升级setuptools:输入”pip install --upgrade setuptools“后,显示如下:
$ pip install --upgrade setuptools
Collecting setuptools
Downloading setuptools-45.2.0-py3-none-any.whl (584 kB)
|████████████████████████████████| 584 kB 206 kB/s
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 41.2.0
Uninstalling setuptools-41.2.0:
Successfully uninstalled setuptools-41.2.0
Successfully installed setuptools-45.2.0
我理解为:”升级成功“。
③安装turtle库,输入“pip install turtle”后,显示如下:
$ pip install turtle
Collecting turtle
Using cached turtle-0.0.2.tar.gz (11 kB)
ERROR: Command errored out with exit status 1:
command: /data/data/com.termux/files/usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-6dvij44j/turtle/setup.py'"'"'; file='"'"'/data/data/com.termux/files/usr/tmp/pip-install-6dvij44j/turtle/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /data/data/com.termux/files/usr/tmp/pip-install-6dvij44j/turtle/pip-egg-info
cwd: /data/data/com.termux/files/usr/tmp/pip-install-6dvij44j/turtle/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/data/data/com.termux/files/usr/tmp/pip-install-6dvij44j/turtle/setup.py", line 40
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
我理解为,“安装错误。”仔细看了看提示内容,看不懂。
④按照您提示的网址看了下,修改了安装程序的第40行代码,但下面又不会了。困惑疑点有两个:
⒈在win7里,把安装包解压后,打开setup.py,修改了第40行代码,然后,是不是需要还打包回味回去呢?还是直接就这样解压状态安装?
  ⒉在termux里,如何表示文件所在位置的路径?
我现在感觉自己开车在路上,但遇到了大雾,走不动啊。

老菜苗 | 园豆:161 (初学一级) | 2020-02-23 17:07

@老菜苗: termux这个我没用过,不知道跟Linux有没有什么区别,解压状态安装还是重新打包,你自己都试试,看看这个https://jingyan.baidu.com/article/cb5d6105b09d6a005d2fe040.html

风行天下12 | 园豆:3867 (老鸟四级) | 2020-02-24 09:31

@风行天下12:非常感谢您的回复。您介绍的文章我看过了,是通过文件管理器确定文件存储位置。类似的文件管理器我也用过。但都需要root。当我百度相关root方法时,各种root有风险的恐吓,主要是不愿意再花时间折腾了(也有一部分被吓到了)
其实我又想到了一个办法,就是在Termux上挂载U盘,这样就可以对文件进行操作了。
目前还在探索中。

老菜苗 | 园豆:161 (初学一级) | 2020-02-26 16:59

@老菜苗: ok

风行天下12 | 园豆:3867 (老鸟四级) | 2020-02-26 17:01

@风行天下12: 挂载u盘的方法找到了,如果有兴趣可以看一下。
https://www.cnblogs.com/laocm/p/12369258.html
另外,还涉及到安装本地包的问题。
虽然turtle 库安上了,但还是没法用。底子太薄,看不懂,不想继续研究了,等有时间再捣鼓。

老菜苗 | 园豆:161 (初学一级) | 2020-02-27 12:26

@老菜苗: 好呢,我也看看, termux这个没用过,也算多了解点知识

风行天下12 | 园豆:3867 (老鸟四级) | 2020-02-27 12:27

@风行天下12: 如果有闲的时间,可以捣鼓捣鼓,安卓手机上的Linux 模拟器,还是可以做好多事的。但,如果象我一样,本身对Linux 就没基础,那就别弄这个termux了,很多坑。

老菜苗 | 园豆:161 (初学一级) | 2020-02-27 12:32
其他回答(1)
0

首先要有pip
然后

pip install turtle
KimBing_Ng | 园豆:352 (菜鸟二级) | 2020-02-23 09:26

在termux里输入命令pip install turtle 出现以下错误提示:
$ pip3 install turtle
Collecting turtle
Using cached turtle-0.0.2.tar.gz (11 kB)
ERROR: Command errored out with exit status 1:
command: /data/data/com.termux/files/usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-2svapp16/turtle/setup.py'"'"'; file='"'"'/data/data/com.termux/files/usr/tmp/pip-install-2svapp16/turtle/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /data/data/com.termux/files/usr/tmp/pip-install-2svapp16/turtle/pip-egg-info
cwd: /data/data/com.termux/files/usr/tmp/pip-install-2svapp16/turtle/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/data/data/com.termux/files/usr/tmp/pip-install-2svapp16/turtle/setup.py", line 40
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
$ pkg install python-turtle
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-turtle
$ pip install turtle
Collecting turtle
Using cached turtle-0.0.2.tar.gz (11 kB)
ERROR: Command errored out with exit status 1:
command: /data/data/com.termux/files/usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-xxt5pwqd/turtle/setup.py'"'"'; file='"'"'/data/data/com.termux/files/usr/tmp/pip-install-xxt5pwqd/turtle/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /data/data/com.termux/files/usr/tmp/pip-install-xxt5pwqd/turtle/pip-egg-info
cwd: /data/data/com.termux/files/usr/tmp/pip-install-xxt5pwqd/turtle/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/data/data/com.termux/files/usr/tmp/pip-install-xxt5pwqd/turtle/setup.py", line 40
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

支持(0) 反对(1) 老菜苗 | 园豆:161 (初学一级) | 2020-02-23 10:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册