AllenNLP v1.5.0 No module named 'allennlp.data.tokenizers.word_splitter' - spacy

I got an import error as :
from allennlp.data.tokenizers.word_splitter import SpacyWordSplitter
ModuleNotFoundError: No module named'allennlp.data.tokenizers.word_splitter'
Also allennlp.data.tokenizers.word_splitter no longer exists in the latest version of AllenNLP.
It has been replaced with SpacyTokenizer. So what would be the correct version of Spacy to use for a tokenizer in AllenNLP v1.5.0?

Related

tensorflow import bug: No module named 'tensorflow.python.eager.polymorphic_function'

I am trying to import the tensorflow module in my jupyter notebook, however this error appears. I have imported ternsorflow before, therefore I am not cure why it is showing the error: ModuleNotFoundError: No module named 'tensorflow.python.eager.polymorphic_function' . Could someone help me fix this?
I tried checking if tensorflow is installed, and indeed it is.

"no module named numpy.core" error after installing numpy in a layer in AWS Lambda

When I deployed my serverless FastAPI with AWS Lambda and API Gateway I got the following error:
No module named numpy.core. Unable to import module 'path/to/handler': Unable to import required dependencies: numpy
And I also got this:
The python version is: Python3.7 from "var/lang/bin/python3.7" , the numpy version is: "1.21.6"
I have installed the numpy module in a layer and included the path to the directory where the module is installed in the serverless.yml file and I still experience the "no module named numpy.core" error.
My serverless.yml file looks like this:
layers:
something:
compatibleRuntimes:
- python3.8
- python3.7
- python3.6
path: 'path/to/layer'
I also tried without the compatibleRuntimes block, and I still got the same error.
I think that since the numpy module is installed and the correct version is being used, it is likely that the issue is not related to the numpy module itself.
And, actually, in my code, what I import is the pandas module, but when I install pandas, it also installs numpy.
import pandas as pd
# functions
Any advice or tip? I have been stuck in this for a long time. Thank you in advance!

Tensorflow 2x - ModuleNotFoundError: No module named 'tensorflow.contrib'

I'm working on a Tensorflow project that needs to be upgraded to use tensorflow==2.2.0, and can no longer work with Tensorflow 1.x, due to comparability with other packages.
However, after upgrading, I'm getting the below error:
File "/opt/app-root/lib/python3.6/site-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/opt/app-root/lib/python3.6/site-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/opt/app-root/lib/python3.6/site-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ModuleNotFoundError: No module named 'tensorflow.contrib'
The only help I can find regarding this error is to downgrade.
What, if any, is the recommend approach to migrate up to Tensorflow 2.x when using tflearn?
It is not directly possible. You have to rebuild different routines and several functions need to be altered accordingly. There are not 100% differences between 1.X and 2.X version, but at-least some functions are new and some old options are deprecated. If you upgrade step by step, you can see there are deprecation warnings for next level upgradations.

DLL load failure upon attempt to import sklearn modules

I'm trying to import a scikit-learn module
from sklearn.model_selection import train_test_split
and receive the error message
File "C:\Software\Anaconda\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py", line 45, in <module>
from . import _arpack
ImportError: DLL load failed: The specified procedure could not be found.
I'm not the first person to encounter this issue
(Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found)
but neither of the remedies suggested in that discussion
uninstall/reinstall scipy
modify the fixes.py file
solved my problem. Any new ideas would be appreciated.

pyttsx: No module named 'engine'

I'm trying to install TTS package by using this. Everything was okay until I tried to execute the following command:
import pyttsx
I got back this error:
File "/usr/local/lib/python3.4/dist-packages/pyttsx/__init__.py", line 18, in module <br>
from engine import Engine<br>
ImportError: No module named 'engine'
Any help would be appreciated. Thank you!
Guys there is an updated package compatible with Python3 :
pyttsx3
Works offline with no delay in the sound produced.
Installation:
pip install pyttsx3
Visit https://pyttsx3.readthedocs.io for the full usage docs.
Thanks!
Combining the advice from Jacob Tsui and Jokhongir Mamarasulov worked for me. To summarize:
In site_packages/pyttsx/init.py, modify "from engine import Engine" to
from .engine import Engine
Then, in site_packages/pyttsx/engine.py,
Modify import driver to
from . import driver
Modify except Exception, e to
except Exception as e
And finally, in site_packages/pyttsx/driver.py modify except Exception, e to
except Exception as e
See the responses from the aforementioned authors for the rationale behind these changes.
I just had the same problem, try using pyttsx3 instead of pyttsx
First install pyttsx3
pip install pyttsx3
and change the
import pyttsx
for
import pyttsx3
After that you have to change engine import (if you're using it in your main .py file). Use engineio instead. Install it
pip install python-engineio
then change import engine for import engineio and change your variables.
Here's an example
import pyttsx3
# import engineio #engineio module is not needed.
engineio = pyttsx3.init()
voices = engineio.getProperty('voices')
engineio.setProperty('rate', 130) # AquĆ­ puedes seleccionar la velocidad de la voz
engineio.setProperty('voice',voices[0].id)
def speak(text):
engineio.say(text)
engineio.runAndWait()
speak("What do you want me to say?")
while(1):
phrase = input("--> ")
if (phrase == "exit"):
exit(0)
speak(phrase)
print(voices)
Hope this helps someone
For Python3, please install the latest version via pip3 install pyttsx3 and call import pyttsx3.
I found out the solution. Library was created in python2 language and there are not a lot of differences between those 2 versions, but exclusively in this case that occurs.
Move to your DP folder and change in engine.py "except Exception as e" instead of "except Exception, e", line 67. Do the same in drive.py, line 105.
Because of files are secured try to execute, e. g.
sudo nano engine.py (or drive.py)
I guess I helped everyone with that kind of problem. :)
Modify site_packages/pyttsx/init.py "from engine import Engine" to
from .engine import Engine
Modify site_packages/pyttsx/engine.py "import driver" to
from . import driver
Reason: The import statement "from engine import Engine" tells python to import Engine module from directory engine. In our case engine is not a directory, it's a python file, engine.py. So we need to tell python to import this engine module from current directory (".").
I used this code after
pip install pywin32 pypiwin32 pyttsx3
and it worked perfectly for me
import os
import sys
import pyttsx3
engine = pyttsx3.init()
engine.say('hello world ')
engine.runAndWait()
I had the same issue.
First Try this command:
pip install pyttsx3
and then don't use
import pyttsx
use this
import pyttsx3
It will work.
pyttsx: No module named 'engine'
File "/usr/local/lib/python3.4/dist-packages/pyttsx/__init__.py", line 18, in module <br>
from engine import Engine<br>
ImportError: No module named 'engine'
If the above one is your error then try install pyttsx3 instead of
pyttsx.
Before installing check your python version, then download the version which is compatible to your python version.
Refer this link to get the previous versions of pyttsx3
REASON:
The reason we get the above error is because of the pyttsx3 version
which is not supported by your python version. Even if you get the error then
FOR pyttsx
Modify the init.py file located in
C:\Users\YOUR USER\AppData\Local\Programs\Python\Python38-32\Lib\site_packages\pyttsx\init.py
Change
from engine import Engine
to
from .engine import Engine
pyttsx
Modify the engine.py file located at C:\Users\YOUR USER\AppData\Local\Programs\Python\Python38-32\Lib\site_packages\pyttsx\engine.py
Change
import driver
to
from . import driver
These are the two main solutions for the above error