Python cannot import name 'NUMPY_MKL' - python-3.x

I am trying to run a wavenet implementation (which uses tensorflow + librosa). However, I keep running into the error "cannot import name 'NUMPY_MKL'".
I have already installed tensorflow, numpy+mk1, scipy and librosa. Tensorflow itself is loading fine, but error is triggered when I run the wavenet implementation which uses librosa.
My spec/details:
Python 3.5.2
Numpy+MK1 (numpy-1.13.1+mkl-cp35-cp35m-win_amd64.whl)
Scipy (scipy-0.19.1-cp35-cp35m-win_amd64.whl)
Windows 10 x64
Nvidia CUDA v8.0 (cudnn 5.1)
Hope you can help. Full error log below:
Traceback (most recent call last):
File "train.py", line 20, in <module>
from wavenet import WaveNetModel, AudioReader, optimizer_factory
File "D:\musicAI\wavenet\__init__.py", line 2, in <module>
from .audio_reader import AudioReader
File "D:\musicAI\wavenet\audio_reader.py", line 7, in <module>
import librosa
File "C:\Python35\lib\site-packages\librosa\__init__.py", line 12, in <module>
from . import core
File "C:\Python35\lib\site-packages\librosa\core\__init__.py", line 108, in <module>
from .time_frequency import * # pylint: disable=wildcard-import
File "C:\Python35\lib\site-packages\librosa\core\time_frequency.py", line 10, in <module>
from ..util.exceptions import ParameterError
File "C:\Python35\lib\site-packages\librosa\util\__init__.py", line 67, in <module>
from .utils import * # pylint: disable=wildcard-import
File "C:\Python35\lib\site-packages\librosa\util\utils.py", line 5, in <module>
import scipy.ndimage
File "C:\Python35\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'

Managed to fixed this by doing a complete uninstall of numpy+mk1, then installing it again.
I was previously doing:
pip install --ignore-install path\numpy.whl
Do this instead to get it working:
pip uninstall numpy # this removes the existing copy
pip install path\numpy.whl # this install the numpy+mk1 from local .whl file

Related

gspread is not imported when running python3 script

Python: Python 3.4.3
OS: Ubuntu 14.04.6 LTS
Hello, I am getting the following error when I try to run my script under Ubuntu. Under Windows, the gspread module was imported without problems. Can you suggest what could be the problem?
Imported modules:
#!/usr/bin/python3
from simplejson import JSONDecodeError
import gspread
import os
Error while running the script:
Traceback (most recent call last):
File "./poverka_python.py", line 5, in <module>
import gspread
File "/usr/local/lib/python3.4/dist-packages/gspread/__init__.py", line 16, in <module>
from .auth import (
File "/usr/local/lib/python3.4/dist-packages/gspread/auth.py", line 16, in <module>
from google_auth_oauthlib.flow import InstalledAppFlow
File "/usr/local/lib/python3.4/dist-packages/google_auth_oauthlib/__init__.py", line 21, in <module>
from .interactive import get_user_credentials
File "/usr/local/lib/python3.4/dist-packages/google_auth_oauthlib/interactive.py", line 27, in <module>
import google_auth_oauthlib.flow
File "/usr/local/lib/python3.4/dist-packages/google_auth_oauthlib/flow.py", line 66, in <module>
import google.auth.transport.requests
File "/usr/local/lib/python3.4/dist-packages/google/auth/transport/requests.py", line 26, in <module>
import requests
File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 48, in <module>
from charset_normalizer import __version__ as charset_normalizer_version
File "/usr/local/lib/python3.4/dist-packages/charset_normalizer/__init__.py", line 24, in <module>
from .api import from_bytes, from_fp, from_path, normalize
File "/usr/local/lib/python3.4/dist-packages/charset_normalizer/api.py", line 71
previous_logger_level: int = logger.level
if you enter "pip3 install gspread"
Requirement already satisfied (use --upgrade to upgrade): gspread in /usr/local/lib/python3.4/dist-packages
Cleaning up...
I have tried installing and reinstalling gspread. Also under Windows everything starts without problems.

./google-cloud-sdk/install.sh triggers error while installing GCloud SDK in ubuntu

Trying to install GCloud SDK in Ubuntu 18.04.
I have python 3.6 installed in the system.
Error says :
Welcome to the Google Cloud CLI!
Traceback (most recent call last):
File "/home/anm/Durgendra Workspace/WebDev/sdk/./google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
import bootstrapping
File "/home/anm/Durgendra Workspace/WebDev/sdk/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
import setup # pylint:disable=g-import-not-at-top
File "/home/anm/Durgendra Workspace/WebDev/sdk/google-cloud-sdk/bin/bootstrapping/setup.py", line 57, in <module>
from googlecloudsdk.core.util import platforms
File "/home/anm/Durgendra Workspace/WebDev/sdk/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/home/anm/Durgendra Workspace/WebDev/sdk/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/home/anm/lib/python3.6/imp.py", line 23, in <module>
from importlib import util
File "/home/anm/lib/python3.6/importlib/util.py", line 13, in <module>
from contextlib import contextmanager
ModuleNotFoundError: No module named 'contextlib'
To solve this I tried to install contextlib using
pip install contextlib2
But this is of no use.

Import error while launching PyTorch Lightning project on Colab TPU

I followed this guide to launch my PyTorch Lightning project on Google Colab TPU. So I installed
!pip install cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-1.9-cp37-cp37m-linux_x86_64.whl
Then
!pip install pytorch-lightning
Then I
!pip install torch torchvision torchaudio
!pip install -r requirements.txt
After installing the project requirements, I restarted the runtime as requested and re-ran the cloud-TPU-client install, the pytorch-lightning install, and both command from above. It ran smoothly.
But just after the TPU has started with version PyTorch version 1.9, I get the following import error :
WARNING:root:TPU has started up successfully with version pytorch-1.9
Traceback (most recent call last):
File "synthesizer_train.py", line 2, in <module>
from synthesizer.train import train
File "/content/Real-Time-Voice-Cloning/synthesizer/train.py", line 6, in <module>
from synthesizer.models.tacotron import Tacotron
File "/content/Real-Time-Voice-Cloning/synthesizer/models/tacotron.py", line 7, in <module>
import pytorch_lightning as pl
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 20, in <module>
from pytorch_lightning.callbacks import Callback # noqa: E402
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/callbacks/__init__.py", line 14, in <module>
from pytorch_lightning.callbacks.base import Callback
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/callbacks/base.py", line 26, in <module>
from pytorch_lightning.utilities.types import STEP_OUTPUT
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
from pytorch_lightning.utilities.apply_func import move_data_to_device # noqa: F401
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 26, in <module>
from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_AVAILABLE
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py", line 101, in <module>
from pytorch_lightning.utilities.xla_device import XLADeviceUtils # noqa: E402
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/xla_device.py", line 24, in <module>
import torch_xla.core.xla_model as xm
File "/usr/local/lib/python3.7/dist-packages/torch_xla/__init__.py", line 142, in <module>
import _XLAC
ImportError: /usr/local/lib/python3.7/dist-packages/_XLAC.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN2at13_foreach_erf_EN3c108ArrayRefINS_6TensorEEE
Trainer was launched with the flag TPU_cores=8.
The model had run on CPU and GPU beforehand (ie on another session).
I tried to downgrade PyTorch to 1.9 (the same as the one shown when TPU is starting) because Colab uses torch 1.10.0+cu111 and a different error appeared :
WARNING:root:TPU has started up successfully with version pytorch-1.9
Traceback (most recent call last):
File "synthesizer_train.py", line 2, in <module>
from synthesizer.train import train
File "/content/Real-Time-Voice-Cloning/synthesizer/train.py", line 6, in <module>
from synthesizer.models.tacotron import Tacotron
File "/content/Real-Time-Voice-Cloning/synthesizer/models/tacotron.py", line 7, in <module>
import pytorch_lightning as pl
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 20, in <module>
from pytorch_lightning.callbacks import Callback # noqa: E402
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/callbacks/__init__.py", line 14, in <module>
from pytorch_lightning.callbacks.base import Callback
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/callbacks/base.py", line 26, in <module>
from pytorch_lightning.utilities.types import STEP_OUTPUT
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
from pytorch_lightning.utilities.apply_func import move_data_to_device # noqa: F401
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 29, in <module>
if _compare_version("torchtext", operator.ge, "0.9.0"):
File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py", line 54, in _compare_version
pkg = importlib.import_module(package)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.7/dist-packages/torchtext/__init__.py", line 5, in <module>
from . import vocab
File "/usr/local/lib/python3.7/dist-packages/torchtext/vocab/__init__.py", line 11, in <module>
from .vocab_factory import (
File "/usr/local/lib/python3.7/dist-packages/torchtext/vocab/vocab_factory.py", line 4, in <module>
from torchtext._torchtext import (
ImportError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZTVN5torch3jit6MethodE
Is there anything I can do to train the model on TPU ?
Thank you very much
Actually the same problem has also been described and the suggested solution did work for me.
So in the details they suggest to downgrade PyTorch to 1.9.0+cu111 (mind the +cu111) after installing torch_xla.
Consequently here are the steps I followed to launch my Lightning project on Google Colab with TPU :
!pip install cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-1.9-cp37-cp37m-linux_x86_64.whl
!pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchtext==0.10.0 -f https://download.pytorch.org/whl/cu111/torch_stable.html
And then the project's pip :
!pip install torch torchvision torchaudio pytorch-lightning
!pip install -r requirements.txt
And it worked even though after this last step, I had to restart runtime.
Based on above solution, we could additionally fix the issue for sure by finding the version of cuda installed with
import torch
torch.version.cuda
10.2
Based on this cuda version perform this pip install command
!pip install cloud-tpu-client==0.10 torchvision==0.12.0+cu102 torch==1.11.0+cu102 https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-1.11-cp37-cp37m-linux_x86_64.whl -f https://download.pytorch.org/whl/cu102/torch_stable.html
Pls notice the cu102 in three places in the above command

Problem With Tensorflow ,Tried with all versions ,current using Tensorflow version 2.00a0 ,python 3.6 Any idea Regarding this?

Tensorflow version 2.00a0 ,Python 3.6,IDE PyCharm
installed tensorflow framework using
python -m pip install tensorflow --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org
Upgraded using,
pip install tensorflow==2.0.0-alpha0
This is the error.
Traceback (most recent call last):
File "C:/Users/Athish/PycharmProjects/new1/Dashboard.py", line 36, in <module>
from tensorflow.keras.models import load_model
File "C:\Users\Athish\PycharmProjects\new1\venv\lib\site-packages\tensorflow\__init__.py", line 27, in <module>
from tensorflow._api.v2 import audio
File "C:\Users\Athish\PycharmProjects\new1\venv\lib\site-packages\tensorflow\_api\v2\audio\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "C:\Users\Athish\PycharmProjects\new1\venv\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Athish\PycharmProjects\new1\venv\lib\site-
packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "c:\users\athish\pycharmprojects\new1\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

ImportError: Importing the multiarray numpy extension module failed

I am trying to write Python script in Java using ScriptEngine. But when I import tflearn module it gives me following errors.
javax.script.ScriptException: 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
in <script> at line number 1
at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:222)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:59)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at com.ultimatix.bot.JavaRunCommand.main(JavaRunCommand.java:48)
Caused by: Traceback (most recent call last):
File "<script>", line 1, in <module>
File "D:\Python\Lib\site-packages\tflearn\__init__.py", line 4, in <module>
from . import config
File "D:\Python\Lib\site-packages\tflearn\config.py", line 3, in <module>
import tensorflow as tf
File "D:\Python\Lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "D:\Python\Lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
import numpy as np
File "D:\Python\Lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "D:\Python\Lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "D:\Python\Lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "D:\Python\Lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "D:\Python\Lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
I also tried to import some different package like sys, pickle. They are getting imported successfully.
Python version: 3.5.4
OS: Window 7 - 64 bits
Numpy is written in Fortran and compiled to binary. For that reason, it is not compatible to be ran on the JVM. The other packages you are importing are implemented in pure python.
CPython, the standard python implementation, has done a lot of work to stay compatible at the binary level. Numpy arrays have the same memory layout as C arrays, which do not have the same memory layout as Java arrays. As you go deeper into python there are a lot more incompatibilities as to why it won't work.

Categories

Resources