I am using both python Python 2.7.5 and Python 3.4.5. but I am working with Python 3.4.5
There are two users on this server. one user able to import pyodbc without issue. but other account not able to access pyodbc module.
-bash-4.2$ python3
Python 3.4.5 (default, May 29 2017, 15:17:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pyodbc'
Below is pip version
-bash-4.2$ pip3 -V
pip 9.0.1 from /<path to lcaotion>/.local/lib/python3.4/site-packages
(python 3.4)
when try to install pyodbc
pip3 install pyodbc==3.0.10
Getting below error
-bash-4.2$ pip3 install pyodbc==3.0.10
Collecting pyodbc==3.0.10
Using cached pyodbc-3.0.10.tar.gz
Installing collected packages: pyodbc
Running setup.py install for pyodbc ... error
Complete output from command /usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yygzbf28/pyodbc/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-4w_3g87z-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/tmp
creating build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28
creating build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28/pyodbc
creating build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28/pyodbc/src
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=3.0.10 -DPYODBC_UNICODE_WIDTH=4 -DSQL_WCHART_CONVERT=1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include -I/usr/include/python3.4m -c /tmp/pip-build-yygzbf28/pyodbc/src/buffer.cpp -o build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28/pyodbc/src/buffer.o -Wno-write-strings
In file included from /tmp/pip-build-yygzbf28/pyodbc/src/buffer.cpp:12:0:
/tmp/pip-build-yygzbf28/pyodbc/src/pyodbc.h:41:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
Below packages are installed in server
dbus-python.x86_64
libselinux-python.x86_64
newt-python.x86_64
python.x86_64
python-backports.noarch
python-backports-ssl_match_hostname.noarch
python-configobj.noarch
python-configshell.noarch
python-decorator.noarch
python-devel.x86_64
python-ethtool.x86_64
python-iniparse.noarch
python-kmod.x86_64
python-libs.x86_64
python-pcp.x86_64
python-pycurl.x86_64
python-pyudev.noarch
python-rtslib.noarch
python-setuptools.noarch
python-slip.noarch
python-slip-dbus.noarch
python-urlgrabber.noarch
python-urwid.x86_64
python2-crypto.x86_64
python34.x86_64
python34-libs.x86_64
python34-pip.noarch
python34-setuptools.noarch
rpm-python.x86_64
AND also when I tried to install as sudo permission I am getting below
sudo pip3 install pyodbc==3.0.10
Requirement already satisfied: pyodbc==3.0.10 in
/export/home/python/lib/python3.4/site-packages
The issue is unrelated to PIP
fatal error: Python.h: No such file or directory
You are missing your GCC (C++/C Compiler) and Development Tools from your machine - hence the missing C header file
You can install the following YUM group to satisfy the requirement:
RedHat / CentOS:
sudo yum group install "Development Tools"
or
sudo yum groupinstall "Development Tools"
Related
I have both Python 2 and 3 installed in parallel on Ubuntu 18.04.1:
#uname -a
Linux mysvr-1 5.4.0-65-generic #73~18.04.1-Ubuntu SMP Tue Jan 19 09:02:24 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
#python --version
Python 2.7.17
#python3 --version
Python 3.8.8
I am trying to run a script written for Python2 (and which uses simple-crypt which calls pycrypto) using python3 but I cannot install simple-crypt under python3 (pip3) because pycrypto install fails, even though they are both installed fine under python2.
I see the follow errors during install:
#python3 -m pip install simple-crypt
Collecting simple-crypt
Using cached simple-crypt-4.1.7.tar.gz (10 kB)
Collecting pycrypto
Using cached pycrypto-2.6.1.tar.gz (446 kB)
Building wheels for collected packages: simple-crypt, pycrypto
Building wheel for simple-crypt (setup.py) ... done
Created wheel for simple-crypt: filename=simple_crypt-4.1.7-py3-none-any.whl size=8933 sha256=35465628dbc2d4671aef879ccd6d24d09e01ca11afa173fd8d62c5cbcfb8e05b
Stored in directory: /root/.cache/pip/wheels/7f/0b/04/30775cf18395f400fba1112955512e434a896bc5f0592eaf82
Building wheel for pycrypto (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/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-31add99g
cwd: /tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/
Complete output (215 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/Crypto
copying lib/Crypto/pct_warnings.py -> build/lib.linux-x86_64-3.8/Crypto
...
<...many other lines of copying and creating...>
...
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
running build_configure
checking for gcc... gcc
checking whether the C compiler works... yes
...
<...many other successful checks...>
...
checking for memset... yes
configure: creating ./config.status
config.status: creating src/config.h
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash._MD2' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -fwrapv -Wall -fstack-protector-strong -Wformat -Werror=format-security -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python3.8 -c src/MD2.c -o build/temp.linux-x86_64-3.8/src/MD2.o
src/MD2.c:31:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pycrypto
Running setup.py clean for pycrypto
Successfully built simple-crypt
Failed to build pycrypto
Installing collected packages: pycrypto, simple-crypt
Running setup.py install for pycrypto ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/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-record-zy55j0yw/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/pycrypto
cwd: /tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/
Complete output (160 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
...
<...many other lines of copying and creating...>
...
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
running build_configure
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash._MD2' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -fwrapv -Wall -fstack-protector-strong -Wformat -Werror=format-security -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python3.8 -c src/MD2.c -o build/temp.linux-x86_64-3.8/src/MD2.o
src/MD2.c:31:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wo7npi4x/pycrypto_1a5c9f1c1c3446a6a44b1061e80eedc8/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-record-zy55j0yw/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/pycrypto Check the logs for full command output.
#
I thinking it is probably down to this:
src/MD2.c:31:10: fatal error: Python.h: No such file or directory
Questions I have are:
Can I download the package and install from local tar?
Can I install to Python3 from the existing Python2 installation?
Can I tell Python3 how to 'use' packages currently installed under (and usable by) Python2?
Any thoughts/advice?
This is only a partial answer - to Question 1 above:
Can I download the package and install from local tar?
Install Python Module Manually:
# Verify the module is not already installed
python3 -m pip list
# As above - Python 2.x
python -m pip list
# Download the module
curl <MODULE_DOWNLOAD_URL> -o <MODULE_FILE_NAME>
# Make sure setuptools are up to date - Python 3.x
python3 -m pip install --upgrade setuptools
# As above - Python 2.x
python -m pip install --upgrade setuptools
# Extract the downloaded gzipped tar file if necessary
tar -xvf <MODULE_FILE_NAME>
# cd into the extracted module folder if created
cd <MODULE_FOLDER>
# Run the included setup.py script to install the module
python3 setup.py install
# Same for Python 2.x
python setup.py install
# Verify the module was successfully installed
python3 -m pip list
# As above - Python 2.x
python -m pip list
If all went well, the new module should now appear in the list of installed/available modules.
Try pip install pipwin and then pipwin install pycrypto but if this doesn't work it means you might have to downgrade your python version to 3.3 and 1.5.2 is not supported since.this is so because pycrypto was launched in 2013 when python 3.8 wasn't made so there is no support.
As of 2020, installing scipy with pypy is possible. (Is it possible to install scipy under pypy?)
pypy3 -mpip install scipy
However, the wheel fails with this kind of error:
error: Command "g++ -pthread -DNDEBUG -O2 -fPIC -I/tmp/pip-build-env-lfdsn__t/overlay/site-packages/numpy/core/include -I/usr/lib/pypy3/include -c scipy/_lib/_uarray/_uarray_dispatch.cxx -o build/temp.linux-x86_64-3.6/scipy/_lib/_uarray/_uarray_dispatch.o -MMD -MF build/temp.linux-x86_64-3.6/scipy/_lib/_uarray/_uarray_dispatch.o.d -std=c++14 -fvisibility=hidden" failed with exit status 1
ERROR: Failed building wheel for scipy
Failed to build scipy
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
Using --no-use-pep517 option give similar result:
error: Command "g++ -pthread -DNDEBUG -O2 -fPIC -I/home/ezako/.local/lib/pypy3.6/site-packages/numpy/core/include -I/usr/lib/pypy3/include -c scipy/_lib/_uarray/_uarray_dispatch.cxx -o build/temp.linux-x86_64-3.6/scipy/_lib/_uarray/_uarray_dispatch.o -MMD -MF build/temp.linux-x86_64-3.6/scipy/_lib/_uarray/_uarray_dispatch.o.d -std=c++14 -fvisibility=hidden" failed with exit status 1
ERROR: Command errored out with exit status 1: /usr/bin/pypy3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2ffzze2v/scipy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2ffzze2v/scipy/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-record-8avik0f1/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ezako/.local/include/python3.6/scipy Check the logs for full command output.
Numpy has been sucessfully installed with pypy3.
➜ pypy3 -V
Python 3.6.9 (7.3.0+dfsg-1~ppa1~ubuntu19.04, Dec 26 2019, 11:14:16)
[PyPy 7.3.0 with GCC 8.3.0]
Here is what worked for me. I unpacked the latest nightly
pypy -mensurepip
pypy -mpip install --upgrade pip setuptools wheel
pypy -mpip install numpy pybind11
pypy -mpip install scipy
Apparently you need to install pybind11 separately since it does not work properly in a PEP 517 isolated build.
I've got the same problem but none of the solutions that I found helped me.
I tried:
Upgrading pip
Downgrading pip
Use --no-cache-dir flag
Upgrading setuptools and wheel
Use --default-pip flag
Use --no-use-pep517 flag
So I try to install it manually with official manual and everything works fine.
git clone https://github.com/scipy/scipy.git
cd scipy
git submodule update --init
pypy -mpip install .
You may need to set BLAS, LAPACK and ATLAS libraries paths.
I'm trying to pip install tesserocr but encountering the below error.
I've tried a few different ways to install suggested on its doc, all of which with no avail.
At this point I'm certain the issue is not related to this package (since my friend installed it on the his Mac with no problems, I also installed on a Ubuntu VM w/o issue).
The error seems to be c++ library since it cannot find headers or in Tesseract-OCR's source code (?), however before the error line it successfully finds .
I also have pytesseract installed w/o issue.
I'm hoping somebody here can help debug what's causing this issue.
My tesseract (installed through brew) version is:
tesseract 4.0.0
leptonica-1.76.0
libjpeg 9c : libpng 1.6.35 : libtiff 4.0.9 : zlib 1.2.11
Thanks and let me know what other info you might need.
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 /Users/charlieyou/miniconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/2h/ty244jbd1vd3d1l0m4k3_g980000gn/T/pip-install-wgh41bv0/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 /private/var/folders/2h/ty244jbd1vd3d1l0m4k3_g980000gn/T/pip-record-0grp17wc/install-record.txt --single-version-externally-managed --compile:
pkg-config failed to find tesseract/lept libraries: b"Package tesseract was not found in the pkg-config search path.\nPerhaps you should add the directory containing `tesseract.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'tesseract' found\n"
Supporting tesseract v4.0.0
Building with configs: {'libraries': ['tesseract', 'lept'], 'cython_compile_time_env': {'TESSERACT_VERSION': 262144}}
running install
running build
running build_ext
building 'tesserocr' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/charlieyou/miniconda3/include -arch x86_64 -I/Users/charlieyou/miniconda3/include -arch x86_64 -I/usr/local/include -I/Users/charlieyou/miniconda3/include/python3.6m -c tesserocr.cpp -o build/temp.macosx-10.7-x86_64-3.6/tesserocr.o -std=c++11 -DUSE_STD_NAMESPACE
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from tesserocr.cpp:603:
**/usr/local/include/tesseract/unichar.h:24:10: fatal error: 'cstring' file not found
#include <cstring>**
^~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
I had the same problem on my mac,
You should try install the package with conda :
conda install -c mcs07 tesserocr
you can try : xcode-select --install
and I also can't install it , my error message is :
error: command '/usr/bin/clang' failed with exit status 1
I'm trying to install pandas on my python3 installation. Version is 3.4.6, which seems to be the most up to date for this OS. I installed python with:
zypper in python3
I run the command:
pip3 install pandas
It gives me back a log, here is the part where the error is referenced:
gcc -pthread -Wno-unused-result -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g -fwrapv -DOPENSSL_LOAD_CONF -fPIC -Ipandas/_libs/src/klib -Ipandas/_libs/src -I/usr/lib64/python3.4/site-packages/numpy/core/include -I/usr/include/python3.4m -c pandas/_libs/tslib.c -o build/temp.linux-x86_64-3.4/pandas/_libs/tslib.o -Wno-unused-function
gcc: error: unrecognized command line option ‘-fstack-clash-protection’
error: command 'gcc' failed with exit status 1
Failed building wheel for pandas
Running setup.py clean for pandas
Failed to build pandas
Installing collected packages: pandas
Running setup.py install for pandas ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-xvndc9lz/pandas/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-record-nq8ffg3o/install-record.txt --single-version-externally-managed --compile:
Now, I've already googled around, there is a an issue on pip's github which references this problem, but none of the solutions worked.
https://github.com/pypa/pip/issues/5720
Solutions were updating gcc. Mine was initially at version 4.8 but i've already tried 4.9 and 5. Can't go higher than that because YAST is having trouble with dependencies and god know what else.
Any ideas? I think it must be something about the OS, because i've managed to install pandas in another machine, with another linux distro, same python, same gcc..
There is a gcc7 in the "Toolchain Module". SUSEconnect and/or YaST will allow to enable this extra package repository.
I was trying to install pymssql library:
pip install pymssql
It gave the following error:
Collecting pymssql
Downloading https://files.pythonhosted.org/packages/4c/c8/5ad36d8d3c304ab4f310c89d0593ab7b6229568dd8e9cde927311b2f0c00/pymssql-2.1.3.tar.gz (897kB)
100% |████████████████████████████████| 901kB 1.1MB/s
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command /Users/hektor/Sites/venv2/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/rv/vbf7xqh1601_xjkrn85w7hp00000gn/T/pip-install-60za8qcc/pymssql/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/rv/vbf7xqh1601_xjkrn85w7hp00000gn/T/pip-record-vh_omvko/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hektor/Sites/venv2/include/site/python3.5/pymssql:
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
setup.py: Detected Darwin/Mac OS X.
You can install FreeTDS with Homebrew or MacPorts, or by downloading
and compiling it yourself.
Homebrew (http://brew.sh/)
--------------------------
brew install freetds
MacPorts (http://www.macports.org/)
-----------------------------------
sudo port install freetds
setup.py: Not using bundled FreeTDS
setup.py: include_dirs = ['/usr/local/include']
setup.py: library_dirs = ['/usr/local/lib']
running install
running build
running build_ext
building '_mssql' extension
creating build
creating build/temp.macosx-10.11-x86_64-3.5
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/Users/hektor/Sites/venv2/include -I/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c _mssql.c -o build/temp.macosx-10.11-x86_64-3.5/_mssql.o -DMSDBLIB
_mssql.c:266:10: fatal error: 'sqlfront.h' file not found
#include "sqlfront.h"
^~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
As I understand from above that I need to install FreeTDS as indicated in their website
I installed FreeTDS with homebrew:
brew install freetds
After the installation was complete, I tried to run this command again:
pip install pymssql
However I got this error:
-bash: /Users/hektor/Sites/venv2/bin/pip: /Users/hektor/Sites/venv2/bin/python3: bad interpreter: No such file or directory
Additional information:
If I run which python:
/Users/hektor/anaconda2/bin/python
If I run which python3, then nothing returns.
I am using MacOS and my development environment is a virtual environment in my local machine.
How can I fix this problem? I had no such error until I try this pip installation.