I tried to run the snippet of code from the tutorial about NER from deeppavlov.
Link tutorial
First I run command:
python -m deeppavlov install ner_ontonotes_bert_mult
python -m deeppavlov interact ner_ontonotes_bert_mult [-d]
Then
from deeppavlov import configs, build_model
ner_model = build_model(configs.ner.ner_ontonotes_bert_mult, download=True)
ner_model(['World Curling Championship will be held in Antananarivo'])
Catch this error:
ImportError: cannot import name 'convert_examples_to_features'
So if paste code in VSCode, line
configs.ner.ner_ontonotes_bert_mult
will give a signal that "Instance of 'Struct' has no 'ner' member"
(Config is Struct)
How I can fix it?
Google didn 't find an answer
Related
Expected Behavior (local environment: fresh MacOS 12.4 installation)
With no environment updates except $ pip3 install matplotlib, I can successfully run this simple plot from the Matplotlib documentation:
Example Code:
# testplot.py
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
fig.savefig("test.png")
plt.show()
Actual Output (saved to a .png after window opens):
Run $ python3 testplot.py in the terminal:
Observed Behavior (vscode python 3.8 dev container)
Disclaimer: This post does not address notebook-based plots (which work fine but are not always preferred)
However, when I run this in my dev container, I get the following error:
testplot.py:16: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
First Attempted Solution:
Following this previously posted solution, I specified the backend (export MPLBACKEND=TKAgg) before running the interpreter, but the error persists.
Second Attempted Solution:
Following the comments, I added the following lines to the script:
import matplotlib
matplotlib.use('tkagg')
In the v3.8 dev container, this addition changes the error to:
Traceback (most recent call last):
File "testplot.py", line 5, in <module>
matplotlib.use('tkagg')
File "/usr/local/python/lib/python3.8/site-packages/matplotlib/__init__.py", line 1144, in use
plt.switch_backend(name)
File "/usr/local/python/lib/python3.8/site-packages/matplotlib/pyplot.py", line 296, in switch_backend
raise ImportError(
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
Note: adding these two lines broke the local script as well. The point of the local example was to show that it plots stuff without installing anything except matplotlib.
I used Drake Binary Installation for Python from this site
https://drake.mit.edu/python_bindings.html#installation
Then when i checked to ensure I can import pydrake, I have got this:
dmitriy#dmitriy-Lenovo-ideapad-310-15ISK:/opt$ python3 -c 'import pydrake.all; print(pydrake.__file__)'
/opt/drake/lib/python3.8/site-packages/pydrake/__init__.py
But when I try execute this example:
import pydrake.all
builder = pydrake.systems.framework.DiagramBuilder()
plant, _ = pydrake.multibody.plant.AddMultibodyPlantSceneGraph(builder, 0.0)
pydrake.multibody.parsing.Parser(plant).AddModelFromFile(
pydrake.common.FindResourceOrThrow(
"drake/examples/pendulum/Pendulum.urdf"))
plant.Finalize()
diagram = builder.Build()
simulator = pydrake.systems.analysis.Simulator(diagram)
I get this:
No module named 'pydrake'
The documentation you cite shows how to export PYTHONPATH (or alternatively, how to us a virtualenv). Since the first command you posted works, you must have done those steps correctly. Thus, the second command should have also worked.
Maybe you ran the second command in a new terminal, without the correct environment set up?
Import cv2 working in terminal (after typing python3) but not in Pycharm. In Pycharm, I get the following message:
ModuleNotFoundError: No module named 'cv2'
I have installed opencv and the Project Interpreter is Python3.6 in PyCharm.
System paths by using sys.path are:
From Terminal I get:
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/m3z47/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
From PyCharm, I get:
['/home/m3z47/PycharmProjects/Rephrase', '/home/m3z47/PycharmProjects/Rephrase', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/m3z47/PycharmProjects/Rephrase/venv/lib/python3.6/site-packages', '/home/m3z47/PycharmProjects/Rephrase/venv/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg', '/home/m3z47/PycharmProjects/Rephrase/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg']
This question already has answers here:
anaconda - graphviz - can't import after installation
(14 answers)
Closed 3 years ago.
I cannot get graphviz to install and import properly, either using conda install or pip install. I am using jupyter on anaconda.
conda install -c anaconda graphviz
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-0e78fd6401bd> in <module>()
----> 1 import graphviz
2 dot_data = tree.export_graphviz(clf, out_file=None)
3 graph = graphviz.Source(dot_data)
4 graph.render("iris")
ModuleNotFoundError: No module named 'graphviz'
When I install using pip I can successfully import but when I run the below code, I get a very long error message that ends with the following when running graph.render:
from sklearn.datasets import load_iris
from sklearn import tree
import graphviz
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
dot_data = tree.export_graphviz(clf, out_file=None)
graph = graphviz.Source(dot_data)
graph.render("iris")
Below is the end of the end of a long error message:
ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'iris'], make sure the Graphviz executables are on your systems' PATH
I have the directory where the graphviz folders are in PATH.
Anyone have an idea what I am doing wrong?
http://www.graphviz.org/Download_windows.php
Install windows package from: http://www.graphviz.org/Download_windows.php
Install python graphviz package
Add C:\Program Files (x86)\Graphviz2.38\bin to User path
Add C:\Program Files (x86)\Graphviz2.38\bin\dot.exe to System Path
RESTART COMPUTER
Worked for me!
If you're running Linux, you may have to run this command in addition to the Conda command (I had to do this):
sudo apt-get install graphviz
I was getting the exact same error in Pycharm and this solved it.
Grizz-MacBook-Pro:~ Grizz$ cd /usr/local/lib/python2.7/site-packages
Grizz-MacBook-Pro:site-packages Grizz$ ls
PIL pip-6.0.8-py2.7.egg
Pillow-2.7.0-py2.7.egg-info setuptools-12.0.5-py2.7.egg
PyQt4 setuptools.pth
easy-install.pth sip.so
hgext sipconfig.py
homebrew-pillow-nose.pth sipdistutils.py
mercurial sitecustomize.py
mercurial-3.3-py2.7.egg-info sitecustomize.pyc
It looks like PIL is installed in the correct PATH and when I go to use it in Sublime I get the:
'Traceback (most recent call last):
File "/Users/Grizz/Documents/Python Files/Weather APP/WeatherApp.py", line 4, in <module>
from PIL import Image
ImportError: No module named PIL
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/Grizz/Documents/Python Files/Weather APP/WeatherApp.py"]
[dir: /Users/Grizz/Documents/Python Files/Weather APP]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
I'm hoping to figure out either how to change the PIL path to ammend it to my system python path so I can run it in my interpreter or to uninstal and redownload PIL the correct way.
I'm new to Mac OS and have been able to troubleshoot most everything until now. I'm guessing it's because I'm running off my sys Python 2.7 and not a brew installeld 2.7... can someone walk me through this?