pip install re2 报错
pip install re2 gives an error
我正在尝试通过命令 pip install re2
下载 re2,它给了我这个:
Collecting re2
Using cached re2-0.2.22.tar.gz
Building wheels for collected packages: re2
Running setup.py bdist_wheel for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_tul1J/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpEx8yE1pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/re2.cpp:201:29: fatal error: re2/stringpiece.h: No such file or directory
#include "re2/stringpiece.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for re2
Running setup.py clean for re2
Failed to build re2
Installing collected packages: re2
Running setup.py install for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_tul1J/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qsPvRS-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/re2.cpp:201:29: fatal error: re2/stringpiece.h: No such file or directory
#include "re2/stringpiece.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_tul1J/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qsPvRS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_tul1J/re2/
为什么它不起作用?或者我应该通过其他方式下载 re2?
注意:我发现 re2 必须已经安装了 google 的 re2 c++,如果是这个问题,你能告诉我如何安装 google 的 re2 c++ 和 re2以简单的方式?我对他们写的关于如何安装的内容感到困惑。
在尝试了 MattDMo 的解决方案后,我得到了这个:
Collecting re2
Using cached re2-0.2.22.tar.gz
Building wheels for collected packages: re2
Running setup.py bdist_wheel for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-azytbM/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpxFXFdmpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/include/c++/4.9/mutex:35:0,
from /usr/local/include/re2/re2.h:184,
from src/re2.cpp:202:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from src/re2.cpp:202:0:
/usr/local/include/re2/re2.h:734:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag rprog_once_;
^
/usr/local/include/re2/re2.h:735:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag num_captures_once_;
^
/usr/local/include/re2/re2.h:736:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag named_groups_once_;
^
/usr/local/include/re2/re2.h:737:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag group_names_once_;
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for re2
Running setup.py clean for re2
Failed to build re2
Installing collected packages: re2
Running setup.py install for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-azytbM/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hKOqNV-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/include/c++/4.9/mutex:35:0,
from /usr/local/include/re2/re2.h:184,
from src/re2.cpp:202:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from src/re2.cpp:202:0:
/usr/local/include/re2/re2.h:734:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag rprog_once_;
^
/usr/local/include/re2/re2.h:735:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag num_captures_once_;
^
/usr/local/include/re2/re2.h:736:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag named_groups_once_;
^
/usr/local/include/re2/re2.h:737:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag group_names_once_;
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-azytbM/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hKOqNV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-azytbM/re2/
您需要做的就是克隆 libre2
Github repo along with the pyre2
Github 存储库(因为 pip
可用的 PyPI 版本在代码中有错误),构建并安装 libre2
首先,然后构建并安装 pyre2
.
- 启动您最喜欢的终端应用程序。
在您的 $HOME
中创建 src
目录用于存储源代码:
mkdir ~/src
输入src
目录:
cd ~/src
克隆存储库(假设您已安装 git
):
git clone https://github.com/google/re2.git
输入re2
目录:
cd re2
制作:
make
假设没有错误,make install:
sudo make install
克隆 pyre2
github repo
git clone https://github.com/axiak/pyre2.git ~/src/pyre2
切换到仓库目录:
cd ~/src/pyre2
建造:
python setup.py build
安装:
sudo python setup.py install
如果您在 ubuntu,
在调用
之前需要 sudo apt-get install libre2-dev
pip install re2
我遇到了类似的问题。
对我来说,问题是 bash_profile
文件配置不正确。
解决这个问题:
安装jdk
在任何文本编辑器中打开 ~/.bash_profile
或使用 vim ~/.bash_profile
命令
并添加:
export JAVA_HOME=$(/usr/libexec/java_home)
打开终端并运行源命令以应用更改:
source ~/.bash_profile
安装后 re2
使用 pip
pip install re2
我正在尝试通过命令 pip install re2
下载 re2,它给了我这个:
Collecting re2
Using cached re2-0.2.22.tar.gz
Building wheels for collected packages: re2
Running setup.py bdist_wheel for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_tul1J/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpEx8yE1pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/re2.cpp:201:29: fatal error: re2/stringpiece.h: No such file or directory
#include "re2/stringpiece.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for re2
Running setup.py clean for re2
Failed to build re2
Installing collected packages: re2
Running setup.py install for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_tul1J/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qsPvRS-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/re2.cpp:201:29: fatal error: re2/stringpiece.h: No such file or directory
#include "re2/stringpiece.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_tul1J/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qsPvRS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_tul1J/re2/
为什么它不起作用?或者我应该通过其他方式下载 re2?
注意:我发现 re2 必须已经安装了 google 的 re2 c++,如果是这个问题,你能告诉我如何安装 google 的 re2 c++ 和 re2以简单的方式?我对他们写的关于如何安装的内容感到困惑。
在尝试了 MattDMo 的解决方案后,我得到了这个:
Collecting re2
Using cached re2-0.2.22.tar.gz
Building wheels for collected packages: re2
Running setup.py bdist_wheel for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-azytbM/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpxFXFdmpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/include/c++/4.9/mutex:35:0,
from /usr/local/include/re2/re2.h:184,
from src/re2.cpp:202:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from src/re2.cpp:202:0:
/usr/local/include/re2/re2.h:734:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag rprog_once_;
^
/usr/local/include/re2/re2.h:735:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag num_captures_once_;
^
/usr/local/include/re2/re2.h:736:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag named_groups_once_;
^
/usr/local/include/re2/re2.h:737:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag group_names_once_;
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for re2
Running setup.py clean for re2
Failed to build re2
Installing collected packages: re2
Running setup.py install for re2 ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-azytbM/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hKOqNV-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 're2' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-x86_64-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/include/c++/4.9/mutex:35:0,
from /usr/local/include/re2/re2.h:184,
from src/re2.cpp:202:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from src/re2.cpp:202:0:
/usr/local/include/re2/re2.h:734:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag rprog_once_;
^
/usr/local/include/re2/re2.h:735:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag num_captures_once_;
^
/usr/local/include/re2/re2.h:736:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag named_groups_once_;
^
/usr/local/include/re2/re2.h:737:16: error: ‘once_flag’ in namespace ‘std’ does not name a type
mutable std::once_flag group_names_once_;
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-azytbM/re2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hKOqNV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-azytbM/re2/
您需要做的就是克隆 libre2
Github repo along with the pyre2
Github 存储库(因为 pip
可用的 PyPI 版本在代码中有错误),构建并安装 libre2
首先,然后构建并安装 pyre2
.
- 启动您最喜欢的终端应用程序。
在您的
$HOME
中创建src
目录用于存储源代码:mkdir ~/src
输入
src
目录:cd ~/src
克隆存储库(假设您已安装
git
):git clone https://github.com/google/re2.git
输入
re2
目录:cd re2
制作:
make
假设没有错误,make install:
sudo make install
克隆
pyre2
github repogit clone https://github.com/axiak/pyre2.git ~/src/pyre2
切换到仓库目录:
cd ~/src/pyre2
建造:
python setup.py build
安装:
sudo python setup.py install
如果您在 ubuntu, 在调用
之前需要sudo apt-get install libre2-dev
pip install re2
我遇到了类似的问题。
对我来说,问题是 bash_profile
文件配置不正确。
解决这个问题:
安装jdk
在任何文本编辑器中打开 ~/.bash_profile
或使用 vim ~/.bash_profile
命令
并添加:
export JAVA_HOME=$(/usr/libexec/java_home)
打开终端并运行源命令以应用更改:
source ~/.bash_profile
安装后 re2
使用 pip
pip install re2