Install new regex module with setup.py

折月煮酒 提交于 2019-12-09 20:29:57

问题


I'm trying to install the new Regex module

The readme.txt says:::

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

I type in python setup.py install and get back /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

I'm looking for the answer but people keep referring me to the Python docs and they are confusing.

I know it is really simple but I'm just not sure why it isn't working.


回答1:


The implicit first step in these instructions is to download a tarball or zip file of regex, unpack it, go into that directory, and there run “python setup.py install”. See http://docs.python.org/2/install/index.html#the-new-standard-distutils

If you have pip installed, you can avoid these manual steps by running “pip install regex”.




回答2:


It's Easy (On Mac):

  1. Install easy_install curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python
  2. Install pip sudo easy_install pip
  3. Install regex module pip install regex



回答3:


On Ubuntu and Python3.5, I was having an issue where it wasn't compiling when I try to install regex with 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

Solved that by installing python3-dev : sudo apt-get install python3-dev



来源:https://stackoverflow.com/questions/17437564/install-new-regex-module-with-setup-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!