Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用setup.py安装新的正则表达式模块_Python_Regex_Installation_Setup.py - Fatal编程技术网

Python 使用setup.py安装新的正则表达式模块

Python 使用setup.py安装新的正则表达式模块,python,regex,installation,setup.py,Python,Regex,Installation,Setup.py,我正在尝试安装新的正则表达式模块 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

我正在尝试安装新的正则表达式模块

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:无法打开文件'setup.py':[Errno 2]没有这样的文件或目录

我在寻找答案,但人们总是把我指给Python文档,它们让人困惑


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

这些说明中隐含的第一步是下载regex的tarball或zip文件,解压缩它,进入该目录,然后运行“python setup.py install”。看

如果安装了pip,可以通过运行“pip安装正则表达式”来避免这些手动步骤。

这很简单(在Mac上):

  • 轻松安装
    
    卷曲https://bootstrap.pypa.io/ez_setup.py -o-| sudo python
    
  • 安装pip
    
    sudo简易安装pip
    
  • 安装正则表达式模块
    
    pip安装正则表达式
    

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


    通过安装
    python3-dev
    sudo-apt-get-install-python3-dev

    解决了这个问题。您确定已移动到终端中的正确目录吗?不确定。我怎么知道?我需要将文件移动到框架文件夹中吗?我在解压缩的regex文件夹的目录中。然后,我尝试了python setup.py安装,得到了-bash:/Library/Frameworks/python.framework/Versions/Current/bin/python:没有这样的文件或目录,谢谢。它说我仍然有一个错误:运行install_egg_info Writing/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/regex-2013_06_26-py2.7.egg-info Traceback(最后一次调用):文件“setup.py”,第52行,在setup.py中,但我仍然可以导入regex。进一步,您可以显式设置当前版本。e、 g.pip安装正则表达式==2017.4.29
    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