I can't import Keras in Jupyter Notebook - python-3.x

When I run import keras in the Jupyter Notebook cell, it crashes with the following message:
The kernel appears to have died. It will restart automatically.
Keras 2.2.0
jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 5.2.0
jupyter-core 4.4.0
jupyterlab 0.32.1
jupyterlab-launcher 0.10.5
Python 3.6.6
Console import log
kraamis#debian [~]$ python3
Python 3.6.6 (default, Jun 27 2018, 14:44:17)
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
/usr/lib/python3/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
Using TensorFlow backend.
Illegal instruction
tensorflow 1.9.0
tensorflow-gpu 1.9.0
tensorflow-tensorboard 1.5.1

The problem was that my obsolete processor did not support AVX. It was necessary to install the version of tensorflow no older than 1.5

Related

import xarray returns 'No protocol specified'

I have recently updated my xarray, but now am running into an error when I import it:
$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>import xarray
No protocol specified
>>>
What does this mean? Does it have something to do with dependencies on something else? I upgraded using pip3. I do not own this computer, otherwise I would have installed everything with conda. Does pip3 also sort out dependency issues? I heard conda does.. and maybe I should switch over, but I don't want to create a conflict with the other users on the computer.
Maybe this information is also useful:
>>> import xarray
No protocol specified
>>> xarray.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-70-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.10.4
libnetcdf: 4.7.3
xarray: 0.19.0
pandas: 1.3.2
numpy: 1.17.4
scipy: 1.3.3
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.1
h5py: 2.10.0
Nio: None
zarr: 2.4.0+ds
cftime: 1.1.0
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.8.1+dfsg
distributed: None
matplotlib: 3.1.2
cartopy: 0.18.0
seaborn: None
numbagg: None
pint: None
setuptools: 45.2.0
pip: 20.0.2
conda: None
pytest: 4.6.9
IPython: 7.13.0
sphinx: 1.8.5
>>>
This error reflects a problem with how your computer's display is configured, not an error with Xarray.
This answer seems to address the No protocol specified message directly.

No module named 'tensorflow.python.platform'

I am using python3 and have installed tensorflow-gpu using:
pip3 install tensorflow-gpu==1.13.1
And have checked that it is installed by:
pip3 show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.13.1
Summary: TensorFlow is an open source machine learning framework for
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /usr/lib64/python3.6/site-packages
Requires: tensorflow-estimator, keras-applications, termcolor, absl-py, six,
astor, protobuf, wheel, keras-preprocessing, gast, grpcio, numpy,
tensorboard
Required-by:
but when I do the following it gives me an error:
user:/home/mydirectory # python3
Python 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/tensorflow/__init__.py", line 24,
in <module>
from tensorflow.python import pywrap_tensorflow # pylint:
disable=unused-import
File "/usr/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check
ModuleNotFoundError: No module named 'tensorflow.python.platform'
I see from the error that its looking for tensorflow in directory
/usr/lib/python3.6/site-packages/tensorflow
But pip indicates that its installed at
/usr/lib64/python3.6/site-packages
How can I fix this issue?
Please follow below steps..
0) please login with root permission or sudo and write this command in terminal
1)pip3 install tensorflow-gpu==1.13.1
2)pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
3)shekh#shekh:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
https://www.tensorflow.org/install/pip
See https://github.com/tensorflow/tensorflow/issues/374
Are you opening the terminal from within the tensorflow directory?
"Actually I had this issue because I was trying to import tensorflow from a python session inside the tensorflow repo folder, going to some other folder and starting python and importing tensorflow worked for me."
I also had this error and it was solved with this command
python2:
PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages/"
export PYTHONPATH
python3:
PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.6/dist-packages/"
export PYTHONPATH
I encountered a similar error on a Windows 10 system.
There, I had a second tensorflow install under AppData\Roaming\Python\.... This install was likely a product of some previous work that I did not clean up properly, so for me, removing the content of the site-packages directory solved the issue. After that I could import tensorflow without any problems.

Future Warning while importing tensorflow

I just started to learn tensorflow and happened to get through a Future Warning generated by the IPython console.
Here's the block of code:
import tensorflow as tf
x1 = tf.constant(4)
print(x1)
I saved it with the name "hello.py" and executed it on IPython console line by line.
The command gets executed successfully, but ends up with a warning.
Python 3.6.7 |Anaconda, Inc.| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 7.2.0 -- An enhanced Interactive Python.
In [1]: import tensorflow as tf
C:\Users\singh\Anaconda3\lib\site-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
In [2]: x1 = tf.constant(4)
In [3]: print(x1)
Tensor("Const:0", shape=(), dtype=int32)
I can't understand why am I getting this warning. Is there any way to fix this?
Tensorflow version: 1.10.2
Python IDE: Spyder (Anaconda)
OS: Windows 10 x64
use this command line
pip install h5py==2.8.0rc1
there maybe something wrong with package h5py,just upgrade it can solve your problem

Unable to import Pandas in IPython 6.5.0 console (Spyder)

After installing pandas am able to import in cmd as below :
C:\Users\me\Desktop\Django_Project>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>
But when am importing pandas in Spyder in IPython 6.5.0 console I get below error:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 6.5.0 -- An enhanced Interactive Python.
c:\program files (x86)\python37-32\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed. If the frontend dies,
the kernel may be left running. Please let us know
about your system (bitness, Python, etc.) at
ipython-dev#scipy.org
ipython-dev#scipy.org""")
In [1] : import pandas
Traceback (most recent call last):
File "<ipython-input-1-38d4b0363d82>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
In [2] :
Note: I have installed python in "C:\Users\me\AppData\Local\Programs\Python\Python37\" path and environment variables is set as "C:\Users\me\AppData\Local\Programs\Python\Python37;"
And I installed pandas using PIP
Please suggest the solution to resolve this issue.I have tried reinstalling the pandas package almost 6-7 times.
I think you should open anaconda command prompt by searching it in windows search bar . Now write there "conda install -c anaconda pandas" and try again to run the program

Pycharm: why I can't import cabocha library

My os is Mac OS, and I have install successfully conda, and cabocha.
and I can import cabocha.analyze (which is a Yet Another Japanese Dependency Structure Analyzer - GitHub Pages ) successfully in terminal.
(wmm_env) A1706-084:wmm_env k.den$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cabocha.analyzer import CaboChaAnalyzer
>>>
But in the pycharm, there is error:
from cabocha.analyzer import CaboChaAnalyzer
ModuleNotFoundError: No module named 'cabocha'

Resources