Python Module Installation Problems - python

I'm having a ton of trouble installing modules. At first I thought I had messed with my python installation on mac os x but I installed a virtual machine and ubuntu 11.04 and have similar troubles. Why are both os x and ubuntu failing with the same error?
For example I can't install tkinter with it failing:
Installing collected packages: tkinter-pypy
Running setup.py install for tkinter-pypy
building '_tkinter' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_APPINIT -I/usr/include/tcl -I/usr/include/tk -I/usr/include/python2.7 -c src/_tkinter.c -o build/temp.linux-i686-2.7/src/_tkinter.o
src/_tkinter.c:74:17: fatal error: tcl.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/pfm/build/tkinter-pypy/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-sMB5Wi-record/install-record.txt:
running install
running build
running build_ext
building '_tkinter' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_APPINIT -I/usr/include/tcl -I/usr/include/tk -I/usr/include/python2.7 -c src/_tkinter.c -o build/temp.linux-i686-2.7/src/_tkinter.o
src/_tkinter.c:74:17: fatal error: tcl.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/pfm/build/tkinter-pypy/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-sMB5Wi-record/install-record.txt failed with error code 1
Storing complete log in /home/pfm/.pip/pip.log

I encountered exactly the same problem when trying to install tkinter-pypy on Ubuntu 11.04. The error message shows that it's looking for tcl.h file in /usr/include/tcl, but it's not there. I have to install the dev version of the tcl library (I installed tcl8.4-dev).
sudo apt-get install tcl8.4-dev
This installs the header files to /usr/include/tcl8.4. I then created a symlink /usr/include/tcl pointing to that. I also installed the dev version of the tk library (e.g. tk8.4-dev) which installed the tk.h header (needed too by tkinter-pypy) in the /usr/include/tcl directory.
After these steps, tkinter-pypy can be installed successfully.

Not sure about the error, but Tkinter should be available with your Python install. Have you tried to import Tkinter. On a related note I'd definitely recommend using setuptools (aka. easy_install) or one of the other similar installation tools.
EDIT
If Tkinter is still not available, then, on Linux, try locate lib-tk and adding it to your python path
import sys;
sys.path.append(PATH_TO_TK)
Then check out the Wiki to get the setup to stick: http://wiki.python.org/moin/TkInter
Another EDIT
A simple work around might be to install IDLE, which depends on Tkinter (noted by the OP).

Related

error: command 'cc' failed with exit status 1 on Mac for pip install MySQL-python

I need to install MySQL-python through (pip install MySQL-python) on Mac due to this import error:
ImportError: No module named MySQLdb
But there is this error during pip install MySQL-python:
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.14-intel-2.7
cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes
-Qunused-arguments -Qunused-arguments -arch i386
-arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1)
-D__version__=1.2.5 -I/usr/local/opt/mysql-client/include/mysql
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-c _mysql.c -o build/temp.macosx-10.14-intel-2.7/_mysql.o
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
I tried different solutions provided by Stackoverflow such as:
"'cc' failed with exit status 1" error when install python library or command 'cc' failed with exit status 1 on OSX High Sierra but still getting the same error.
Any suggestions or comments to resolve this?
Further info:
(virt-env) m-c0:fz$ which python
/usr/bin/python
(virt-env) m-c0:fz$ which pip
/usr/local/bin/pip
(virt-env) m-c0:fz$ python --version
Python 2.7.16
export PATH="/usr/local/opt/cython/bin:$PATH"
export PATH="/Users/zf/Library/Python/2.7/bin:$PATH"
export PATH=$PATH:/usr/local/Cellar/mysql/8.0.18_1/bin
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
You don't have mysql C libraries installed on your Mac OS, there are multiple options to install it.
You can install it easy fi you have brew installed on your Mac OS, or google for other options to install the libs using your env.
More info
Can't install mysql-python with pip on MacOS 10.12.4
https://ruddra.com/posts/install-mysqlclient-macos/
https://medium.com/#MrWeeble/homebrew-on-mac-and-pythons-mysqlclient-ea44fa300e70

Error installing mply library. Fatal error: gsl/gsl_sf.h: No such file or directory

I'm trying to install the latest version of mply (3.5.0) on xubuntu (ubuntu 17.10):
download the .tar.gz
Unzipped it
python setup.py build. Here I get the error displayed below.
also tried directly python setup.py install. same error.
tried installing gsl library by downloading the latest version, and following all the steps in https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/. I have it installed in /home/gsl
still the same error
tried various other installations (sudo apt-get install libgsl0ldbl, sudo apt-get install libgs123, sudo apt-get install libgsl0-dev). Nothing works.
tried copying the folder /home/gsl/include/gsl inside the mply-3.5.0/mply/gsl folder . this slightly changes something, because now I get fatal error: gsl/gsl_sf_result.h: No such file or directory (So it finds gsl_sf.h, but not gsl_sf_result.h (both these files are present inside the /gsl/include/gsl folder).
tried with
python setup.py build_ext --include-dirs=/home/gls/include/gls
still nothing
tried to copy the /home/gsl/include/gsl folder inside my /usr/local/include:
cp -R /home/gsl/include/gsl /usr/local/include/gsl
still nothing.
Help!
Error message:
gcc -pthread -B /home/lorenzo/anaconda3/compiler_compat
-Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -I/home/lorenzo/anaconda3/include/python3.6m
-I/home/lorenzo/anaconda3/lib/python3.6/site-packages/numpy/core/include
-I/home/lorenzo/anaconda3/include/python3.6m -c mlpy/gsl/gsl.c
-o build/temp.linux-x86_64-3.6/mlpy/gsl/gsl.o
mlpy/gsl/gsl.c:223:10: fatal error: gsl/gsl_sf.h: No such file or directory
#include "gsl/gsl_sf.h"
SOLVED by re-installing gsl library using conda:
conda install gsl

Can't install C-based modules like lxml and Cython on Python 3.6 on Raspberry Pi

I built Python 3.6 from source and am trying to install lxml. Trying to install it from pip gives the following error:
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/local/include/python3.6m -c src/lxml/etree.c -o build/temp.linux-armv6l-3.6/src/lxml/etree.o -w
src/lxml/etree.c:91:20: fatal error: Python.h: No such file or directory
compilation terminated.
Compile failed: command 'gcc' failed with exit status 1
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitln68cjsn.c -o tmp/xmlXPathInitln68cjsn.o
cc tmp/xmlXPathInitln68cjsn.o -L/usr/lib -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
The same error is raised if I try to install Cython to compile lxml from source. I installed libxml2-dev and libxslt1-dev, but python3.6-dev, which is apparently also required, is not found in Raspbian repository. I added the following line to /etc/apt/sources.list:
deb http://ftp.de.debian.org/debian sid main
But when trying to install it afterwards, I receive the following error:
The following packages have unmet dependencies:
libdbus-1-3 : Breaks: dbus (< 1.9.16-1~) but 1.6.8-1+deb7u1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
In fact, this error is raised on any package that is found in Debian repository that is not in Raspbian one. What can I do about this?
Since you installed Python from source, you should have the header files already. Should also use header files for the version that you built as opposed to the version in the package manager.
Either
Add the source code directory to includes used by GCC (gcc -I<dir>) or
Install the from source package in a system directory that is automatically included like /usr/include or /usr/local/include
The second option is probably easiest and should be possible from the standard configure/make scripts.

Not able to install lxml verison 3.3.5 in ubuntu

I am using openpyxl python package in my application. I am getting the following message when using the same.
/usr/local/lib/python2.7/dist-packages/openpyxl/init.py:31:
UserWarning: The installed version of lxml is too old to be used with
openpyxl
warnings.warn("The installed version of lxml is too old to be used with openpyxl")
Openpyxl requires lxml version 3.2.5 or above, and the version in my machine is 3.2.0. When I try to upgrade lxml to the latest version ie
3.3.5, it is getting interrupted with the following message.
i686-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/etree.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'i686-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml
Replacing /usr/lib/python2.7/dist-packages/lxml
Replacing /usr/lib/python2.7/dist-packages/lxml-3.2.0.egg-info
Cleaning up...
Removing temporary dir /tmp/pip_build_root...
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ov0PUy-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/lxml
I need help in resolving the issue.
PS:- I have already installed lxml dependent packages python-dev, libxml2-dev and libxslt1-dev in my machine.
sudo pip install --upgrade lxml
On Ubuntu (and other Debian derivatives), before you build some piece of software, ensure that its build dependencies are installed. Using your example, run this:
sudo apt-get build-dep python-lxml
That is likely going to require a whole bunch of packages, one of which is zlib1g-dev, as mentioned.
I think what you're missing is zlib1g-dev.
sudo apt-get install zlib1g-dev
Running above command will solve the issue.

MPICC error when installing mpi4py despite correct and working MPICC installation

I have successfully installed MPICH on Ubuntu 12.04 and can get the simple test C programs to compile and run as expected.
Now I am trying to use pip to install mpi4py, simply via pip install mpi4py. I first executed sudo apt-get build-dep python-mpi4py which worked fine.
I'm working with virtualenv, so this mpi4py installation is not with sudo (and should not be).
Here's the command and the error that I hit after a lengthy set of console output that looks like normal compile stuff (I can print all of the console output if needed, but I think most of it is standard compiler warnings that indicate no problems).
(local-dev)espears#espears-w:~$ pip install mpi4py
src/ext/mpi_swig.c: In function ‘SWIG_Python_AddErrorMsg’:
src/ext/mpi_swig.c:859:5: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
error: command '/usr/bin/mpicc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /home/espears/.virtualenvs/local-dev/bin/python -c "import setuptools, tokenize;__file__='/home/espears/.virtualenvs/local-dev/build/mpi4py/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5o6OwN-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/espears/.virtualenvs/local-dev/include/site/python2.7 failed with error code 1 in /home/espears/.virtualenvs/local-dev/build/mpi4py
Traceback (most recent call last):
File "/home/espears/.virtualenvs/local-dev/bin/pip", line 11, in <module>
sys.exit(main())
File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
return command.main(cmd_args)
File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 31: ordinal not in range(128)
But, which mpicc gives the expected result: /usr/bin/mpicc and as mentioned above, if I use this mpicc to compile simple .c test programs, they work fine.
I've seen some links describing a flag option fPIC for compiling MPI, but, I merely used apt-get to install MPI and specifically want to only rely on native Ubuntu packages for these tools, as opposed to maintaining separate installation instructions for manually building them.
How can I determine why mpicc is failing within the mpi4py installation process?
Added
The following from the console output seems to be the compilation command that causes the trouble.
building 'mpi4py._mpi_swig' extension
/usr/bin/mpicc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/ext/mpi_swig.c -o build/temp.linux-x86_64-2.7/src/ext/mpi_swig.o
This gives the following error when I try from the command line myself:
(local-dev)espears#espears-w:~$ /usr/bin/mpicc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/ext/mpi_swig.c -o build/temp.linux-x86_64-2.7/src/ext/mpi_swig.o
gcc: error: src/ext/mpi_swig.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
I was able to successfully work around this with no changes to anything in my system simply by pointing pip at the MPI4PY package url, rather than the package name:
pip install https://bitbucket.org/mpi4py/mpi4py/downloads/mpi4py-1.3.1.tar.gz
A similar problem was encountered on Ubuntu 18.04 with openmpi-4.0.0.
Solved by installing older version of openmpi-2.1.6.
apt-get install openmpi=2.1.6

Categories

Resources