`TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'edu.stanford.nlp.pipeline.Language'` while importing corenlp in Python - stanford-nlp

TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'edu.stanford.nlp.pipeline.Language'
I am getting this error for this code in Python:
import corenlp
I've been on this issue for over 5 hours now, I am just not able to import corenlp in python for some reason. I have followed all the steps:
pip install corenlp
I also installed protobuf and added it to my path as some solution said that.
My Stanford CoreNLP library version is 4.5.1 which is compatible with the corenlp library.
I am guessing there's some issue with protobuf. Let me know if anybody can fix this!

Related

Rdkit - ImportError: DLL load failed

I have used pip install rdkit-pypi to install rdkit library. But when I type import rdkit as rd, it shows the error
ImportError: DLL load failed while importing rdBase: The specified module was not found.
I am using Anaconda as a base. What should I do to work with rdkit library?
I previously encountered this problem. After some reading, I came to know that the python version above 3.8.0 would not be compatible with rdkit. Even you need to change your base to rdkit.
I solve this by first downgrading the anaconda version with the python version lower than 3.8.0.
then I set my rdkit environment.
In this image u can see my python version and I'm not getting any error
In second image u can see my base to my-rdkit-envs

How do I specify a minimum package version in pipit setup.cfg

I am trying to specify a minimum package version in a pypi setup.cfg file. I have written this:
install_requires =
cocotb>=1.5.2
But I get this error message when I test my package installation:
ERROR: Could not find a version that satisfies the requirement cocotb>=1.5.2 (from pyuvm) (from versions: 1.0.20170128)
ERROR: No matching distribution found for cocotb>=1.5.2
It seems to be using the version number as part of the package name. When I install cocotb manually I see the correct version:
(clean) (base) raysalemi#RayProMac pyuvm % pip list
Package Version
---------- -------
cocotb 1.5.2
All the help I've seen on this refers to the setup.py file, but I am working with the setup.cfg file. What is the syntax to specify a module and version?
The syntax is correct. The problem was that cocotb 1.5.2 is not on test.pypi.org

Azure functions (cloud): Install cython dependent module

I'm trying to install/import a cython dependent module [ZigZag] into my python function on Azure functions (Linux platfrom), I'm working via Windows 8.1 (VSCode), Running Python 3.6 on both local machine and azure functions.
I tried including Cython in the requirements.txt file, this errors out during deployment (seems installation of external modules happens somewhat in parallel)
I tried creating a '.toml' file, no luck.
I also tried the idea found here Python google cloud function deployment failure - Madmom pip package still didn't work.
Finally I decided to deploy the function first (with cython included in the 'requirements.txt' file) without the zigzag module, and then in my python script use subprocess.Popen() to do a pip install zigzag and import it before the rest of the function runs.
This is where I get stuck. In my python file I have these lines included to do the above:
#function to be called in azure __init__.py file
def f....:
# check for zigzag
try:
import zigzag
except ImportError:
subprocess.Popen(["pip", "install", "ZigZag"], shell=True)
finally:
import zigzag
.
.
.
rest of the function...
This deploys successfully to azure functions, however it fails during execution with the error:
Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException :
Result: Failure Exception: ModuleNotFoundError: No module named 'zigzag
Any idea's how to do this correctly?
NB: This issue occurs on google cloud functions as well.
I see this is related to https://learn.microsoft.com/en-us/answers/questions/152557/index.html
As per the thread, the latest version for ZigZag is 0.2.2 and the supported python version is 3.5: https://pypi.org/project/ZigZag/
The azure function supports 3.6 and above python version which will make it incompatible. You can try installing the latest cython using requirements.txt and it will work as expected. But when you try to install ZigZaG it tries to find the dependency of cython package (Cython==0.26.1) that is compatible with it therefor it throws the error that cython package not found.

protoc with grpc_python_plugin: google/protobuf/any.proto: File not found

I'm running this command:
protoc protobuf/file.proto --proto_path=protobuf --proto_path=protobuf --python_out=out/builtin_pb --grpc_out=out/builtin_pb --plugin=protoc-gen-grpc=/usr/local/bin/grpc_python_plugin
where file.proto has:
syntax = "proto3";
import "google/protobuf/any.proto";
And stuff like:
google.protobuf.Any arg = 3;
However, it has the error:
google/protobuf/any.proto: File not found.
bess_msg.proto: Import "google/protobuf/any.proto" was not found or had errors.
bess_msg.proto:251:3: "google.protobuf.Any" is not defined
...
Are there any steps I can follow to make sure any.proto is properly installed?
Thanks
I had this error when trying to compile a protobuf to python on Ubuntu. My problem was that I had installed the compiler using sudo apt install protobuf-compiler, but I had not installed the resources using sudo apt install libprotobuf-dev.
Thanks to this answer for showing me the error of my ways.
I recently encountered this issue and realized that I was using protobuf 3.0. Simply upgrade the protobuf compiler to the latest version (3.6 in my case) for definitions on those types.

Import NLTK : no module NLTK corpus

I have installed NLTK. Here's an image of the installation log.
When i use import nltk i get an error:
"No module named NLTK.corpus"
Here is a screenshot.
What could be the cause?
I think I had the same problem. So, downloading all the packages at once (since question didn't specify).
Start python and then import the packages, exit python and upgrade nltk. Modify the 'all' to download a specific corpus. Took me awhile to complete the 'all' download, I separately downloaded framenet_v15 and restarted the 'all' after. Upgrade nltk when the download is complete.
$ python
>>>import nltk
>>>nltk.download('all')
exit python
$ pip install --upgrade nltk
To fix this, you should rename your file to something else, say nltkXXX.py. Also make sure to remove "nltk.pyc" from your directory if it exists, since this will also be loaded (it's the byte compiled version of your code). After that, it should work fine.
If you are using the latest version of python, then try installing nltk using pip and the wheel downloaded from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Then in command prompt, use the command:
pip3 install
This should install nltk correctly.
After that check the installation in python using the command:
import nltk
and download the nltk data required using:
nltk.download()
If you find (Import NLTK : no module NLTK corpus) that type of error .
Make sure your saved file not be the name like (nltk.py).
so just rename your file name (like rename nltk.py to example.py ) or something else:
I hope it will help you.
thanks
If you has using PyCharm IDE, you should have install NLTK from the IDE's own tools [File -> Settings -> Projetct Interpreter -> Install (button '+') -> Install Package].

Resources