从源安装 setuptools "No module named numbers" 错误

Installing setuptools from source "No module named numbers" error

这是基于Install Python Flask without using pip

我的环境没有安装或启用 rpm,也没有 pip、easy_install、virtualenv 等

根据链接问题中的答案,我需要安装 setuptools 才能安装 Jinja。

为此,我下载并解压了 setuptools-19.1.1.tar.gz。然后我 运行 以下命令并得到一个 ImportError:

$python setup.py install

 Traceback (most recent call last):
 File "setup.py", line 21, in <module>
 exec(init_file.read(), command_ns)
 File "<string>", line 11, in <module>
 File "/misc/scratch/flask-files/setuptools-19.1.1/setuptools/__init__.py", line 12, in <module>
 from setuptools.extension import Extension
 File "/misc/scratch/flask-files/setuptools-19.1.1/setuptools/extension.py", line 8, in <module>
 from .dist import _get_unpatched
 File "/misc/scratch/flask-files/setuptools-19.1.1/setuptools/dist.py", line 7, in <module>
 import numbers
ImportError: No module named numbers

有谁知道在哪里可以获取数字模块?我找不到那会是什么。

谢谢!

我找到了我自己问题的答案。使用 Ubuntu 机器,我使用

进入我的 python 终端
python -v

并尝试导入号码:

>>> import numbers
# /usr/lib/python2.7/numbers.pyc matches /usr/lib/python2.7/numbers.py
import numbers # precompiled from /usr/lib/python2.7/numbers.pyc
# /usr/lib/python2.7/__future__.pyc matches /usr/lib/python2.7/__future__.py
import __future__ # precompiled from /usr/lib/python2.7/__future__.pyc

这告诉我数字模块位于 /usr/lib/python2.7。在我当前的环境中,我的 /usr/lib/python2.7/site-packages 目录中没有任何内容。因此,我将工作 Ubuntu 环境中的所有文件 scp 到我的空服务器,这样我就有了可用的数字模块(加上我将来可能需要的任何其他东西)。

现在 运行 python setup.py 在我的 setuptools 上安装就可以了。

您可以将源代码从 github 复制到本地文件 /usr/lib/python3.5/numbers.py.