3

我正在尝试安装新的 Regex 模块

readme.txt 说:::

To build and install regex for your default Python run 

    python setup.py install

To install regex for a specific version run setup.py with that interpreter, e.g.

    python3.1 setup.py install

我输入python setup.py install并返回/Library/Frameworks/Python.framework/Versions/7.3/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory

我正在寻找答案,但人们一直在向我介绍 Python 文档,他们很困惑。

我知道这很简单,但我只是不确定为什么它不起作用。

4

3 回答 3

4

这些说明中隐含的第一步是下载正则表达式的 tarball 或 zip 文件,解压缩,进入该目录,然后运行“python setup.py install”。请参阅http://docs.python.org/2/install/index.html#the-new-standard-distutils

如果您安装了 pip,则可以通过运行“pip install regex”来避免这些手动步骤。

于 2013-07-03T14:17:25.860 回答
1

很简单(在 Mac 上):

  1. 安装easy_install curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python
  2. 安装点子 sudo easy_install pip
  3. 安装正则表达式模块 pip install regex
于 2015-03-21T22:18:47.083 回答
0

UbuntuandPython3.5上,当我尝试regex使用 pip( pip install regex) 安装时遇到了无法编译的问题:

Building wheels for collected packages: regex
  Running setup.py bdist_wheel for regex ... error
  Complete output from command /var/www/envs/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-i08laat0/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-xlh43fe_ --python-tag cp35:
  /var/www/envs/lib/python3.5/site-packages/setuptools/dist.py:397: UserWarning: Normalizing '2018.02.21' to '2018.2.21'
    normalized_version,
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  copying regex_3/regex.py -> build/lib.linux-x86_64-3.5
  copying regex_3/_regex_core.py -> build/lib.linux-x86_64-3.5
  copying regex_3/test_regex.py -> build/lib.linux-x86_64-3.5
  running build_ext
  building '_regex' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/regex_3
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/var/www/envs/include/python3.5m -c regex_3/_regex.c -o build/temp.linux-x86_64-3.5/regex_3/_regex.o
  regex_3/_regex.c:46:20: fatal error: Python.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for regex
  Running setup.py clean for regex
Failed to build regex

通过安装解决了这个问题python3-devsudo apt-get install python3-dev

于 2018-04-24T08:20:27.830 回答