installing python packages Ubuntu 14.04 LTS - python-2.7

I'm having troubles installing python (2.7.6) modules in my Ubuntu 14.04 LTS. I have just tried to install module numpy (and others) and when I import it, I have the following output:
python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/usr/lib/python2.7/dist-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /usr/local/bin/gex/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
I already tried to update, upgrade, install with pip and so many other things and just became withouot extra options to try around here...
Could anyone give any light on what the problem might be?
Thanks in advance!
Cheers

Many thanks to everyone who read and tried to help, specially #jkalden. I managed to reinstall gfortran manually by downloading the package (deb file). Everything is working fine...so far...!
Once again, thank you all for the inputs.

Related

AttributeError: 'module' object has no attribute 'float32'

I am trying to use OpenNMT-py with python 2.7. OpenNMT-py requires torchtext, so I installed it but now when I am running my program, I am getting the following error message.
Traceback (most recent call last):
File "examples/StackPointerParser.py", line 23, in <module>
from neuronlp2.io import get_logger, conllx_stacked_data
File "./neuronlp2/__init__.py", line 7, in <module>
from . import models
File "./neuronlp2/models/__init__.py", line 4, in <module>
from .parsing import *
File "./neuronlp2/models/parsing.py", line 15, in <module>
from onmt.modules import LayerNorm, Transformer
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/__init__.py", line 1, in <module>
import onmt.io
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/io/__init__.py", line 1, in <module>
from onmt.io.IO import collect_feature_vocabs, make_features, \
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/io/IO.py", line 8, in <module>
import torchtext.data
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/__init__.py", line 1, in <module>
from . import data
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/__init__.py", line 4, in <module>
from .field import RawField, Field, ReversibleField, SubwordField, NestedField, LabelField
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/field.py", line 61, in <module>
class Field(RawField):
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/field.py", line 115, in Field
torch.float32: float,
AttributeError: 'module' object has no attribute 'float32'
I tried to look for a solution to resolve this issue but couldn't find any. Any help would be appreciated.
This is more a guess, as you have not given information about your version. But it seems to me that your torchtext version is not compatible with your PyTorch version.
Probably when you installed torchtext you got the newer version already made for PyTorch 0.4.0. But your PyTorch version installed is still older than 0.4.0 (version 0.3.1 or so).
If that is the case you have two options. Downgrading torchtext to a version compatible to yours (probably the version before). Or upgrading PyTorch to version 0.4.0.
I hope this helps.
What's your pytorch version? As per the readme of the github repo of torchtext :
For PyTorch versions before 0.4.0, please use pip install torchtext==0.2.3.
I was facing this exact problem with pytorch 0.3.1 and torchtext 0.3.0. I uninstalled torchtext and then installed it with
pip install torchtext==0.2.3.
And it worked for me. Let me know if you face any other problems.

Numpy error with python 2.7.12

I have both python2.7 and python3.5 installed on Ubuntu 16.04. After I write import numpy in python2.7 environment, I get the following error,
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name multiarray
But with python3 I am facing no such trouble with numpy. Please suggest a solution if anyone has faced similar issue.
you are importing a version of Numpy who are for python 3.5
you must download the version who are for 2.7
you can find the download packages of numpy as : http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

Installing tensorflow for Python 2.7 when already have for Python 3.5

I have tensorflow already installed for Python 3.5 in Ubuntu 16.04, and when I import it, I get the following message:
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
/usr/local/lib/python3.5/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
>>>
But with Python2.7, I get this:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
I tried to install tensorflow after installing cuDNN, Cuda, bumblebee, nvidia driver etc., but after I rebooted, I couldn't get past the login screen. After a friend of mine fixed the problem, I still wanna use tensorflow with Python 2.7, how can I do so without messing up my system? I have cuda 9.1 installed.
Have you tried virtualenv to manage your pip packages? you can easily use it to avoid multi-version of tensorflow and Python,

python ImportError: No module named Tkinter

Every time I tried to run import matplotlib,
I have error ImportError: No module named Tkinter.
The output result is as listed below:
Python 2.7.5 (default, Aug 2 2016, 04:20:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/usr/lib/python2.7/site-packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/usr/lib/python2.7/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/site-packages/six.py", line 82, in _import_module
__import__(name)
ImportError: No module named Tkinter
I tried to install the tk.x86_64 and tk-devel.x86_64 packages, and tried to reinstall the python package but the error still appeared.
Also I tried to import Tkinter but I got the following error.
Python 2.7.5 (default, Aug 2 2016, 04:20:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Tkinter
Does anyone have a workaround for this error?
I'm using python2.7.12 on ubuntu16.04.
I installed it with this command:
sudo apt-get install python-tk
I tried to install tkinter package for python2.7.5 from the following link:
tkinter package
Also I found there is dependency library libTix.so()(64bit) for tkinter package and i got it from the following link: libTix.so()(64bit) package
after that i installed both then I could import Tkinter and import matplotlib.pyplot as plt with no errors.
My 2 cents. Open a terminal and type the following.
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>>
If you do not get an error like below then your Tkinter is fine and the problem is with matplotlib. Then try removing and reinstalling matplotlib.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tkinter
I was getting the error "ImportError: No module named '_tkinter'" for python3.5 in-spite of installing python3-tk and tkinter-dev.
It showed the error in following file:
File "/usr/local/lib/python3.5/tkinter/init.py", line 35, in
import _tkinter # If this fails your Python may not be configured for Tk
It got resolved for me by simply running the python from /usr/bin like /usr/bin/python3.5 from terminal!
In short, please ensure the python version being run from terminal has the tkinter installed and configured :)
My PC configuration: Ubuntu16.04 with default python2.7 and python3.5
I faced the same issue on a RHEL 7 machine. There was no python-tk package that could be installed. I found the solution here which solved the issue for me:
sudo yum install tkinter
This should work for RHEL machines using Python 2.

Installing GDAL 2.1 64-bit for Python 2.7, Windows 7

Ah, yes, back to the joy of installing GDAL.
This time, I need to install GDAL 2.1 for Python 2.7, 64-bit, on Windows 7. I used these installers for the Python bindings and GDAL core, and set the appropriate path variables. I am using Numpy 1.10.4.
In the Command Prompt:
gdalinfo --version
> GDAL 2.1.0, released 2016/04/25
In Python:
>>> Python 2.7.11 ... MSC v.1500 64 bit(AMD64) on win32
from osgeo import gdal
gdal.__version__
>>> '2.1.0'
So far, so good. But, it fails to find _gdal_array.pyd when trying to read a dataset to a Numpy array:
ds = gdal.Open("test.tif")
data = ds.ReadAsArray()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
ds.ReadAsArray()
File "C:\Python27\lib\site-packages\osgeo\gdal.py", line 1825, in ReadAsArray
import gdalnumeric
File "C:\Python27\lib\site-packages\osgeo\gdalnumeric.py", line 1, in <module>
from osgeo.gdal_array import *
File "C:\Python27\lib\site-packages\osgeo\gdal_array.py", line 26, in <module>
_gdal_array = swig_import_helper()
File "C:\Python27\lib\site-packages\osgeo\gdal_array.py", line 18, in swig_import_helper
import _gdal_array
ImportError: No module named _gdal_array
Has anyone been able to install GDAL 2.1 successfully on a 64-bit system?
If you downloaded from source and installed numpy just after the build. You need to rebuild e reinstall the gdal/swig/python.
Hope it helps!