pip install regex Fails to build on Anaconda python3.6.9 virtualenv - python

I'm using anaconda 64bits on a manjaro distribution. I created a python3.6 enviroment using conda create -n tensorflow python=3.6 anaconda.
I also installed pip install tensorflow-gpu==1.12 and conda install cudnnif that matters.
On my original python 3.7 outside of anaconda (/usr/bin/python3) it installs fine, but when I enter the virtualenv by conda activate tensorflow, and try to install by pip install regex==2017.4.5 it yelds an error.
Other versions of the package seem to be getting the same error, it is not version specific.
See the error message below:
Installing collected packages: regex [25/1582]
Running setup.py install for regex ... error
ERROR: Command errored out with exit status 1:
command: /opt/anaconda/anaconda3/envs/tensorflow/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jcrdpn4y/regex/setup.py'"'"'; __file__='"'"'/tmp$
pip-install-jcrdpn4y/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'e$
ec'"'"'))' install --record /tmp/pip-record-if4z1bod/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-jcrdpn4y/regex/
Complete output (56 lines):
/opt/anaconda/anaconda3/envs/tensorflow/lib/python3.6/site-packages/setuptools/dist.py:472: UserWarning: Normalizing '2017.04.05' to '2017.4.5'
normalized_version,
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying Python3/regex.py -> build/lib.linux-x86_64-3.6
copying Python3/_regex_core.py -> build/lib.linux-x86_64-3.6
copying Python3/test_regex.py -> build/lib.linux-x86_64-3.6
running build_ext
building '_regex' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/Python3
gcc -pthread -B /opt/anaconda/anaconda3/envs/tensorflow/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/anaconda/anaconda3/e$
vs/tensorflow/include/python3.6m -c Python3/_regex.c -o build/temp.linux-x86_64-3.6/Python3/_regex.o
Python3/_regex.c: In function ‘do_best_fuzzy_match’:
Python3/_regex.c:16731:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
16731 | for (i = 0; i < best_list.count; i++) {
| ^
Python3/_regex.c:16765:77: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
16765 | if (state->total_errors < error_limit || i == 0 &&
| ~~~~~~~^~
16766 | offset == 0)
| ~~~~~~~~~~~
Python3/_regex.c: In function ‘do_match’:
Python3/_regex.c:16624:9: warning: ‘status’ may be used uninitialized in this function [-Wmaybe-uninitialized]
16624 | int status;
| ^~~~~~
Python3/_regex.c:16776:32: warning: ‘better’ may be used uninitialized in this function [-Wmaybe-uninitialized]
16776 | if (better) {
| ^
Python3/_regex.c:16763:34: note: ‘better’ was declared here
16763 | BOOL better;
| ^~~~~~
Python3/_regex.c:16772:76: warning: ‘best_match_pos’ may be used uninitialized in this function [-Wmaybe-uninitialized]
16772 | better = state->reverse ? state->match_pos >
| ~~~~~~~~~~~~~~~~~^
16773 | best_match_pos : state->match_pos <
| ~~~~~~~~~~~~~~
Python3/_regex.c:16717:24: note: ‘best_match_pos’ was declared here
16717 | Py_ssize_t best_match_pos;
| ^~~~~~~~~~~~~~
Python3/_regex.c: In function ‘pattern_subx’:
Python3/_regex.c:20715:20: warning: ‘kwargs’ may be used uninitialized in this function [-Wmaybe-uninitialized]
20715 | item = PyObject_Call(replacement, args, kwargs);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python3/_regex.c:20715:20: warning: ‘args’ may be used uninitialized in this function [-Wmaybe-uninitialized]
gcc -pthread -B /opt/anaconda/anaconda3/envs/tensorflow/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/anaconda/anaconda3/en
vs/tensorflow/include/python3.6m -c Python3/_regex_unicode.c -o build/temp.linux-x86_64-3.6/Python3/_regex_unicode.o
gcc -pthread -shared -B /opt/anaconda/anaconda3/envs/tensorflow/compiler_compat -L/opt/anaconda/anaconda3/envs/tensorflow/lib -Wl,-rpath=/opt/anaconda/anaconda3/envs/tensorflow/lib -Wl,--
no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/Python3/_regex.o build/temp.linux-x86_64-3.6/Python3/_regex_unicode.o -o build/lib.linux-x86_64-3.6/_regex.cpython-36m-x86_64-linux-gn
u.so
/opt/anaconda/anaconda3/envs/tensorflow/compiler_compat/ld: build/temp.linux-x86_64-3.6/Python3/_regex.o: unable to initialize decompress status for section .debug_info
/opt/anaconda/anaconda3/envs/tensorflow/compiler_compat/ld: build/temp.linux-x86_64-3.6/Python3/_regex.o: unable to initialize decompress status for section .debug_info
/opt/anaconda/anaconda3/envs/tensorflow/compiler_compat/ld: build/temp.linux-x86_64-3.6/Python3/_regex.o: unable to initialize decompress status for section .debug_info
/opt/anaconda/anaconda3/envs/tensorflow/compiler_compat/ld: build/temp.linux-x86_64-3.6/Python3/_regex.o: unable to initialize decompress status for section .debug_info
build/temp.linux-x86_64-3.6/Python3/_regex.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/anaconda/anaconda3/envs/tensorflow/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jcrdpn4y/regex/s
etup.py'"'"'; __file__='"'"'/tmp/pip-install-jcrdpn4y/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exe
c(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-if4z1bod/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Some things I noticed above:
Upon building, the error message pointed out file not recognized: file format not recognized
Something called "ld" exited a fail status on the building process collect2: error: ld returned 1 exit status. I suppose this is just to signify that something went wrong while builind on /run/ or /usr/temp, but it may be helpful.
I don't actually believe it's a problem with gcc, since other packages install fine.
I also don't believe it to be an error of system-wide dependencies, because outside of the virtualenv everything works fine.
And please keep in mind: I am using a manjaro, arch distributions don't have -dev or -devel packages (e.g. python-devel) to install separatelly. Normally those come included with the original package (i.e. python or python3).
Thanks for any help :).

I've searched a little more on the topic, and it seems that my OS is very much involved. The problem seems to be in kernel toolkit level stuff, and a bit more upstream than I imagine. Waiting for someone to close the question. Will post on Super User stack exchange.
https://github.com/mne-tools/mne-python/issues/6071
https://bbs.archlinux.org/viewtopic.php?id=242682

Maybe you should try to using:
conda install regex
instead of pip.

Related

Installing python tables on mac with m1 chip

I am trying to use tables in python3 on a new mac mini with the M1 chip.
I am getting multiple errors when running HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.0_1 pip3 install tables
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/setup.py'"'"'; __file__='"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/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 /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-wheel-_1y0kbny
cwd: /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-vok5ylwx/tables_cf9b90e841c543338af0578c772dd962/
Complete output (293 lines):
* Using Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:10:52)
* USE_PKGCONFIG: False
* Found HDF5 headers at ``/opt/homebrew/Cellar/hdf5/1.12.0_1/include``, library at ``/opt/homebrew/Cellar/hdf5/1.12.0_1/lib``.
.. WARNING:: Could not find the HDF5 runtime.
The HDF5 shared library was *not* found in the default library
paths. In case of runtime problems, please remember to install it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/lzo_version_date5uv_p4uz.c:2:5: error: implicit declaration of function 'lzo_version_date' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
lzo_version_date();
^
1 error generated.
* Could not find LZO 2 headers and library; disabling support for it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/lzo_version_datewh6xukqc.c:2:5: error: implicit declaration of function 'lzo_version_date' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
lzo_version_date();
^
1 error generated.
* Could not find LZO 1 headers and library; disabling support for it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/BZ2_bzlibVersion0fv_km8c.c:2:5: error: implicit declaration of function 'BZ2_bzlibVersion' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
BZ2_bzlibVersion();
^
1 error generated.
* Could not find bzip2 headers and library; disabling support for it.
/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/blosc_list_compressorsqqaoy5ob.c:2:5: error: implicit declaration of function 'blosc_list_compressors' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
blosc_list_compressors();
^
1 error generated.
* Could not find blosc headers and library; using internal sources.
SSE2 detected and enabled
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'extra_require'
warnings.warn(msg)
I installed blosc and tried to install python-lzo via pip install python-lzo but get
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/setup.py'"'"'; __file__='"'"'/private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/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 /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-wheel-c1_ztyik
cwd: /private/var/folders/wf/6qtzk3b11fxfpw2r195w68v40000gn/T/pip-install-7vr_mnqv/python-lzo_a324aed1764741928cf19a18f366c948/
Complete output (12 lines):
running bdist_wheel
running build
running build_ext
building 'lzo' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.9
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/include/lzo -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c lzomodule.c -o build/temp.macosx-10.9-x86_64-3.9/lzomodule.o
lzomodule.c:35:10: fatal error: 'lzo/lzo1x.h' file not found
#include <lzo/lzo1x.h>
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for python-lzo
Bonus points if you can help me understand why tables was never an issue on python2 (admittedly on a Windows machine, but I am getting all similar errors there too on python3)
These steps works for me.
Install Homebrew for Mac M1 (arm64 version)
Then install packages
brew install hdf5 c-blosc lzo bzip2
Check installation path
brew info -q hdf5 c-blosc lzo bzip2|grep '/opt/homebrew'
/opt/homebrew/Cellar/hdf5/1.12.0_3 (268 files, 19.4MB) *
/opt/homebrew/Cellar/c-blosc/1.21.0 (10 files, 1.5MB) *
/opt/homebrew/Cellar/lzo/2.10 (31 files, 580.4KB) *
/opt/homebrew/Cellar/bzip2/1.0.8 (26 files, 531.5KB)
...
Download and unarchive PyTables(PyTables-3.6.1 for me)
Compile
cd PyTables-3.6.1
python setup.py build --hdf5=/opt/homebrew/Cellar/hdf5/1.12.0_3 --use-pkgconfig=FALSE --blosc=/opt/homebrew/Cellar/c-blosc/1.21.0 --lzo=/opt/homebrew/Cellar/lzo/2.10 --bzip2=/opt/homebrew/Cellar/bzip2/1.0.8
Install
python setup.py install --hdf5=/opt/homebrew/Cellar/hdf5/1.12.0_3
UPDATE(2021-11-15): conda works now
conda install pytables
The tables module can be easily installed using Miniforge (which can be easily installed using pyenv or following their installation instructions):
https://github.com/conda-forge/miniforge
Once Miniforge is installed you can install tables on your M1 Mac using:
conda install pytables
You may try this link
https://github.com/PyTables/PyTables/issues/219#issuecomment-24117053
After many searches, I was able to install tables by setting the HDF5_DIR and
pip install git+https://github.com/PyTables/PyTables.git#master#egg=tables

pip install tesserocr fails with error " Failed building wheel for tesserocr"

I already have the latest builds for leptonica and tesseract
tesseract 4.00.00alpha-365-gcf0b378
leptonica-1.74.1
libjpeg 8d (libjpeg-turbo 1.3.0) : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8
i have also installed all dependencies like python-dev
This the error i'm getting when i do pip install tesserocr in my
virtualenv
Collecting tesserocr
Using cached tesserocr-2.1.3.tar.gz
Building wheels for collected packages: tesserocr
Running setup.py bdist_wheel for tesserocr ... error
Complete output from command /home/ajay/virtualenvs/v2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L3JmI9/tesserocr/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/tmpUIPX1spip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
Supporting tesseract v4.00.00dev
Configs from pkg-config: {'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}, 'library_dirs': ['/usr/local/lib'], 'include_dirs': ['/usr/local/include']}
cythoning tesserocr.pyx to tesserocr.cpp
building 'tesserocr' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/local/include -fPIC -I/usr/local/include -I/usr/include/python2.7 -c tesserocr.cpp -o build/temp.linux-x86_64-2.7/tesserocr.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/local/include/tesseract/genericvector.h:29:0,
from tesserocr.cpp:449:
/usr/local/include/tesseract/helpers.h: In member function ‘void tesseract::TRand::set_seed(const string&)’:
/usr/local/include/tesseract/helpers.h:50:5: error: ‘hash’ is not a member of ‘std’
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:26: error: expected primary-expression before ‘>’ token
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:28: error: ‘hasher’ was not declared in this scope
std::hash<std::string> hasher;
^
tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
tesserocr.cpp:16699:106: error: no matching function for call to ‘tesseract::TessPDFRenderer::TessPDFRenderer(__pyx_t_9tesseract_cchar_t*&, const char*)’
__pyx_t_7 = new tesseract::TessPDFRenderer(__pyx_v_outputbase, __pyx_v_self->_baseapi.GetDatapath());
^
tesserocr.cpp:16699:106: note: candidates are:
In file included from tesserocr.cpp:459:0:
/usr/local/include/tesseract/renderer.h:190:3: note: tesseract::TessPDFRenderer::TessPDFRenderer(const char*, const char*, bool)
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly);
^
/usr/local/include/tesseract/renderer.h:190:3: note: candidate expects 3 arguments, 2 provided
/usr/local/include/tesseract/renderer.h:186:16: note: tesseract::TessPDFRenderer::TessPDFRenderer(const tesseract::TessPDFRenderer&)
class TESS_API TessPDFRenderer : public TessResultRenderer {
^
/usr/local/include/tesseract/renderer.h:186:16: note: candidate expects 1 argument, 2 provided
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for tesserocr
Running setup.py clean for tesserocr
Failed to build tesserocr
Installing collected packages: tesserocr
Running setup.py install for tesserocr ... error
Complete output from command /home/ajay/virtualenvs/v2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L3JmI9/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-6eGBXb-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ajay/virtualenvs/v2/include/site/python2.7/tesserocr:
running install
running build
running build_ext
Supporting tesseract v4.00.00dev
Configs from pkg-config: {'libraries': ['lept', 'tesseract'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}, 'library_dirs': ['/usr/local/lib'], 'include_dirs': ['/usr/local/include']}
skipping 'tesserocr.cpp' Cython extension (up-to-date)
building 'tesserocr' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/usr/local/include -fPIC -I/usr/local/include -I/usr/include/python2.7 -c tesserocr.cpp -o build/temp.linux-x86_64-2.7/tesserocr.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/local/include/tesseract/genericvector.h:29:0,
from tesserocr.cpp:449:
/usr/local/include/tesseract/helpers.h: In member function ‘void tesseract::TRand::set_seed(const string&)’:
/usr/local/include/tesseract/helpers.h:50:5: error: ‘hash’ is not a member of ‘std’
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:26: error: expected primary-expression before ‘>’ token
std::hash<std::string> hasher;
^
/usr/local/include/tesseract/helpers.h:50:28: error: ‘hasher’ was not declared in this scope
std::hash<std::string> hasher;
^
tesserocr.cpp: In function ‘tesseract::TessResultRenderer* __pyx_f_9tesserocr_13PyTessBaseAPI__get_renderer(__pyx_obj_9tesserocr_PyTessBaseAPI*, __pyx_t_9tesseract_cchar_t*)’:
tesserocr.cpp:16699:106: error: no matching function for call to ‘tesseract::TessPDFRenderer::TessPDFRenderer(__pyx_t_9tesseract_cchar_t*&, const char*)’
__pyx_t_7 = new tesseract::TessPDFRenderer(__pyx_v_outputbase, __pyx_v_self->_baseapi.GetDatapath());
^
tesserocr.cpp:16699:106: note: candidates are:
In file included from tesserocr.cpp:459:0:
/usr/local/include/tesseract/renderer.h:190:3: note: tesseract::TessPDFRenderer::TessPDFRenderer(const char*, const char*, bool)
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly);
^
/usr/local/include/tesseract/renderer.h:190:3: note: candidate expects 3 arguments, 2 provided
/usr/local/include/tesseract/renderer.h:186:16: note: tesseract::TessPDFRenderer::TessPDFRenderer(const tesseract::TessPDFRenderer&)
class TESS_API TessPDFRenderer : public TessResultRenderer {
^
/usr/local/include/tesseract/renderer.h:186:16: note: candidate expects 1 argument, 2 provided
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I get this error at the bottom
----------------------------------------
Command "/home/ajay/virtualenvs/v2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-L3JmI9/tesserocr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-6eGBXb-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ajay/virtualenvs/v2/include/site/python2.7/tesserocr" failed with error code 1 in /tmp/pip-build-L3JmI9/tesserocr/
Finally fixed the issue
completely removed tesseract and leptonica from the system and built everything from source
the debian package leptonica-dev for ubuntu 14.04 was the problem
these are the current builds i've compiled
$ tesseract -v
tesseract 3.04.01
leptonica-1.74.1
libjpeg 8d (libjpeg-turbo 1.3.0) : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8

Install Fabric error in pyenv

I want use Fabric when I product my project in AWS Ubuntu. When I read about Fabric, it required python 2.5~2.7, so I create Python virtualenv on Mac OS X:
pyenv virtualenv 2.7.5 fabric
mkdir fabric
and I run pip install fabric
(fabric)fabric $ pip install fabric
but it has 2 errors
Collecting fabric
[...]
configure: creating ./config.status
config.status: creating src/config.h
building 'Crypto.PublicKey._fastmath' extension
creating build/temp.macosx-10.11-x86_64-2.7
creating build/temp.macosx-10.11-x86_64-2.7/src
clang -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/Users/hanminsoo/.pyenv/versions/2.7.5/include/python2.7 -c
src/_fastmath.c -o build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o
src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
2 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/hanminsoo/.pyenv/versions/2.7.5/lib build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.11-x86_64-2.7/Crypto/PublicKey/_fastmath.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
------------------------------------------------------
Failed building wheel for pycrypto
Running setup.py clean for pycrypto
Failed to build pycrypto
Installing collected packages: pycrypto, paramiko, fabric
Running setup.py install for pycrypto ... error
Complete output from command /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-iE2TRI-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/include/site/python2.7/pycrypto:
clang -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/Users/hanminsoo/.pyenv/versions/2.7.5/include/python2.7 -c src/_fastmath.c -o build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o
src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
else if (result < 0)
~~~~~~ ^ ~
2 warnings generated.
clang -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/hanminsoo/.pyenv/versions/2.7.5/lib build/temp.macosx-10.11-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.11-x86_64-2.7/Crypto/PublicKey/_fastmath.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
-------------------------------------------------------
Command "/Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-iE2TRI-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hanminsoo/.pyenv/versions/2.7.5/envs/fabric/include/site/python2.7/pycrypto" failed with error code 1 in /private/var/folders/c5/d1_cb4j92f19h5q0_cbv7bpc0000gn/T/pip-build-vsA2vJ/pycrypto/
Some people tell me "you should install pycrpto" so I install pycrpto
pip install pycrpto
but it has the same error when I pip install fabric. I found this solution link, so I run:
brew install gmp
export LIBRARY_PATH=/usr/local/lib
pip install pycrypto
but it has the same error and second solution is link
$ bunzip2 gmp-5.0.5.tar.bz2
but it has another error:
bunzip2: Can't open input file gmp-5.0.5.tar.bz2: No such file or directory.
I can't understand why fabric doesn't install...
It's a bug in Python <2.7.8. See pyenv#273.
You can fix it by patching _sysconfigdata.py:
$ export p=/Users/andrei/.pyenv/versions/2.7.6
$ sed -i -e "s#python.exe#${p}/bin/python2.7#g" "$p/lib/python2.7/_sysconfigdata.py"

pip install getch : clang error

I am trying to install getch via pip and I have a clang error :
python -m pip install getch
Collecting getch
Using cached getch-1.0.tar.gz
Installing collected packages: getch
Running setup.py install for getch ... error
Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-uEGRgA-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'getch' extension
creating build
creating build/temp.macosx-10.10-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c getchmodule.c -o build/temp.macosx-10.10-x86_64-2.7/getchmodule.o
getchmodule.c:36:6: warning: unused variable 'ok' [-Wunused-variable]
int ok = PyArg_ParseTuple(args, "");
^
getchmodule.c:43:6: warning: unused variable 'ok' [-Wunused-variable]
int ok = PyArg_ParseTuple(args, "");
^
getchmodule.c:55:4: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
PyModuleDef_HEAD_INIT,
^
getchmodule.c:54:27: error: variable has incomplete type 'struct PyModuleDef'
static struct PyModuleDef getchmodule = {
^
getchmodule.c:54:15: note: forward declaration of 'struct PyModuleDef'
static struct PyModuleDef getchmodule = {
^
getchmodule.c:64:9: warning: implicit declaration of function 'PyModule_Create' is invalid in C99 [-Wimplicit-function-declaration]
return PyModule_Create(&getchmodule);
^
3 warnings and 2 errors generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-uEGRgA-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/
I am using Mac so cannot use msvcrt.
Thank you for your help.
The installation is failing because it's looking for python3 headers. Looking at https://pypi.python.org/pypi/getch there are two source distributions listed, getch-1.0-python2.tar.gz and getch-1.0.tar.gz.
For python 2 you need the former of those, but it looks like the latter one is being chosen (same thing happens for me). I'm not sure if/how pip is supposed to be able to know how to choose the correct one, but you can choose manually:
copying the link,
pip install https://pypi.python.org/packages/source/g/getch/getch-1.0-python2.tar.gz#md5=586ea0f1f16aa094ff6a30736ba03c50
works for me

Error updating pycups via pip

I'm running openSUSE Leap 42.1 and I just tried to update all the software in pip, using the following command:
for i in $(pip list|awk '{print $1}'); do pip install $i --upgrade;done
This hit a few errors, I had some missing devel dependencies, which I managed to fix, and most of the packages then updated fine, but one continues to fail, and I'm not sure why. The errors at this point became a bit cryptic and my google-fu was unable to find the answer. Can anyone advise why I'm getting this error, and whether there is a way to fix/work around?
Collecting pycups
Using cached pycups-1.9.73.tar.bz2
Installing collected packages: pycups
Found existing installation: pycups 1.9.72
DEPRECATION: Uninstalling a distutils installed project (pycups) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling pycups-1.9.72:
Successfully uninstalled pycups-1.9.72
Running setup.py install for pycups
Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-vpyfl_ln/pycups/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zukh_f21-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'cups' extension
creating build
creating build/temp.linux-x86_64-3.4
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -DVERSION="1.9.73" -I/usr/include/python3.4m -c cupsmodule.c -o build/temp.linux-x86_64-3.4/cupsmodule.o
cupsmodule.c: In function ‘cups_connectDest’:
cupsmodule.c:720:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
int i;
^
cupsmodule.c:743:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
PyObject *largs = Py_BuildValue ("()");
^
cupsmodule.c: In function ‘PyInit_cups’:
cupsmodule.c:1018:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
struct module_state *st = GETSTATE(m);
^
cupsmodule.c:1026:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
PyObject *d = PyModule_GetDict (m);
^
cc1: some warnings being treated as errors
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of pycups
Command "/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-vpyfl_ln/pycups/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zukh_f21-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-vpyfl_ln/pycups
I'm using the following pip:
pip 7.1.2 from /usr/lib/python3.4/site-packages (python 3.4)
The problem is this compiler flag: -Werror=declaration-after-statement. You need to tell the compiler not to turn this warning into an error by setting the CFLAGS environment variable:
CFLAGS=-Wno-error=declaration-after-statement pip install -U pycups

Categories