ImportError: cannot import name 'pytext_config_from_json' from 'pytext.config.serialize' - pytext

I'm trying to fine-tune XLM-R model by following this colab notebook.
While running the following cell in kaggle notebook
from pytext.config.serialize import pytext_config_from_json
I'm getting the error
ImportError: cannot import name 'pytext_config_from_json' from 'pytext.config.serialize' (/opt/conda/lib/python3.7/site-packages/pytext/config/serialize.py)
I have installed pytext by
!pip install --quiet git+https://github.com/facebookresearch/pytext
Thanks

Try
from pytext.config import pytext_config_from_json

Related

Not able to import simpletransformers.ner in python as it says ImportError: cannot import name 'BertweetTokenizer'

I am trying to do bert based NER and trying to import,
from simpletransformers.ner import NERModel, NERArgs
I have installed simpletranformers in pip and when I try to import,
import simpletransformers.ner
it says, ImportError: cannot import name 'BertweetTokenizer'. When I try to install BertweetTokenizer, it throws
ERROR: No matching distribution found for BertweetTokenizer
Not sure, what I am missing. Kindly help

Error in %conda list biopython in jupyter notebook (macOS)

I use jupyter notebook, I have anaconda installed on the system. I get this error when I import Bio
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-de5ff3e63c39> in <module>
----> 1 from Bio import Phylo
2 import wget
3 import re
4 from Bio import SeqIO
5 from Bio.SeqRecord import SeqRecord
ModuleNotFoundError: No module named 'Bio'
and when I look at the packages in this path /Users/morteza/anaconda3/lib/python3.7/site-packages/, bio and biopython are there
Can somebody help me with this?
Thanks
I found a solution so I share here maybe will be useful for someone. I changed the name bio to Bio in the path /Users/morteza/anaconda3/lib/python3.7/site-packages/ using mv bio Bio command then the import worked properly.

Apache Lounge server is not responding for rpy2 package on windows machine

import rpy2.robjects as robjects
from rpy2.robjects import pandas2ri
Apache + mod_wsgi + python 3.x configuration is working pretty nice on my windows machine. It is rpy2 package which is actually giving me trouble. However the same piece of code is working for me in the command line/IDLE.
I tried putting this configuration in the httpd.conf file from the below shared link:
WSGIApplicationGroup %{GLOBAL}
https://serverfault.com/questions/514242/non-responsive-apache-mod-wsgi-after-installing-scipy
Still no luck..
Code where it's failing:
import rpy2.robjects as robjects
from rpy2.robjects import pandas2ri
def calculate_from_data(self, path):
pandas2ri.activate()
r = robjects.r
print("running R.........")
filepath = path + os.sep + 'vectorization.R'
r.source(filepath)
vectorize = r['vectorize']
matrix = vectorize(self.base_data.df)
Apache should give me the same result as running those code in command line/IDLE gives?. Need help on this please..
For example: piece of code which is executing as expected from CMD/IDLE:
import rpy2.rinterface as rinterface
from rpy2.robjects.packages import importr
print("initializing...")
rinterface.initr()
print(" done.")
print("Mapping the R base package...")
base = importr('base')
print(" done.")
output:
initializing...
done.
Mapping the R base package...
done.
But the same code is not working on Apache.

Darkflow without GPU on Jupyter-Notebook - Simple Code Required

I am unable to setup & run a simple darkflow program. Infact can't even configure darkflow library:
from darkflow.net.build import TFNet
==> ModuleNotFoundError: No module named 'darkflow'
My Target is to run the following program:
from darkflow.net.build import TFNet
import cv2
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
tfnet = TFNet(options)
imgcv = cv2.imread("./test/dog.jpg")
result = tfnet.return_predict(imgcv)
print(result
Please suggest steps so that I could configure darkflow on Jupyter Notebook (with no GPU) and run the above code
Fixed by creating the file in ipynb file in darkflow directory (downloaded from github) and executing the following from the notebook:
!python3 setup.py build_ext --inplace
!pip install -e .
!pip install .

ImportError: cannot import name 'label_map_util'

I'm running on Python 3.6.5 (64bits) trying to run the object_detection_tutorial.
I receive this message when I run the programm :
ImportError: cannot import name 'label_map_util'
Any idea on what I should do ?
Edit : I tried to see whether or not I installed the API and got this :
C:\tensorflow\models-master>python object_detection/protos/label_map_util_test.py
python: can't open file 'object_detection/protos/label_map_util_test.py': [Errno 2] No such file or directory
Try this instead...
from object_detection.utils import label_map_util
Get current dir :
os.getcwd()
change current dir :
os.chdir( '../models/research/object_detection' )
CD to object_detection directory
And you can replace
from utils import label_map_util to
from object_detection.utils import label_map_util
and
from utils import visualization_utils as vis_util to
from object_detection.utils import visualization_utils as vis_util

Resources