Import Error of IBM Watson Natural Language Understanding API - ibm-cloud

I am now trying to extract keywords by using IBM Watson Natural Language Understanding API. I follow the instruction and have installed the watson_developer_cloud. However, I met an error when import the NaturalLanguageUnderstandingV1. Could you help me with it? Thank you!
from watson_developer_cloud import NaturalLanguageUnderstandingV1
Traceback (most recent call last):
File "<ipython-input-11-ab5aa6f014f4>", line 1, in <module>
from watson_developer_cloud import NaturalLanguageUnderstandingV1
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-
packages\watson_developer_cloud\__init__.py", line 30, in <module>
rom .speech_to_text_v1 import SpeechToTextV1
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-
packages\watson_developer_cloud\speech_to_text_v1.py", line 74, in <module>
from watson_developer_cloud.websocket import RecognizeCallback, RecognizeListener
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\watson_developer_cloud\websocket\__init__.py", line 18, in <module>
from .speech_to_text_websocket_listener import RecognizeListener
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\watson_developer_cloud\websocket\speech_to_text_websocket_listener.py", line 21, in <module>
from twisted.internet import ssl, reactor
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\twisted\internet\ssl.py", line 59, in <module>
from OpenSSL import SSL
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\OpenSSL\crypto.py", line 16, in <module>
from OpenSSL._util import (
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: The operating system cannot run %1.

After reinstalling the watson-cloud-developer as an administrator. I solve the problem. It seems that if we do not run the pip install command as an administrator, then the package cannot be installed correctly.

Related

I run odoo 15 on vs-code but these errors appear what the solution for these?

The errors is:
( /usr/bin/env /bin/python3 /home/abdulrahman/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 37511 -- /home/abdulrahman/odoo/odoo-15.0/odoo-bin --config=/home/a /usr/bin/env /bin/python3 /home/abdulrahman/.vscode/extensions/ms-python.python-2022.16.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 37511 -- /home/abdulrahman/odoo/odoo-15.0/odoo-bin --config=/home/abdulrahman/odoo/config/odoo15.conf
Traceback (most recent call last):
File "/home/abdulrahman/odoo/odoo-15.0/odoo-bin", line 5, in
import odoo
File "/home/abdulrahman/odoo/odoo-15.0/odoo/init.py", line 113, in
from . import modules
File "/home/abdulrahman/odoo/odoo-15.0/odoo/modules/init.py", line 8, in
from . import db, graph, loading, migration, module, registry
File "/home/abdulrahman/odoo/odoo-15.0/odoo/modules/graph.py", line 10, in
import odoo.tools as tools
File "/home/abdulrahman/odoo/odoo-15.0/odoo/tools/init.py", line 8, in
from . import pdf
File "/home/abdulrahman/odoo/odoo-15.0/odoo/tools/pdf.py", line 18, in
from odoo.tools.misc import file_open
File "/home/abdulrahman/odoo/odoo-15.0/odoo/tools/misc.py", line 35, in
import babel
File "/home/abdulrahman/.local/lib/python3.10/site-packages/babel/init.py", line 20, in
from babel.core import UnknownLocaleError, Locale, default_locale, \
File "/home/abdulrahman/.local/lib/python3.10/site-packages/babel/core.py", line 14, in
from babel import localedata
File "/home/abdulrahman/.local/lib/python3.10/site-packages/babel/localedata.py", line 17, in
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/init.py)bdulrahman/odoo/config/odoo15.conf
Traceback (most recent call last):
File "/home/abdulrahman/odoo/odoo-15.0/odoo-bin", line 5, in
import odoo
File "/home/abdulrahman/odoo/odoo-15.0/odoo/init.py", line 113, in
from . import modules
File "/home/abdulrahman/odoo/odoo-15.0/odoo/modules/init.py", line 8, in
from . import db, graph, loading, migration, module, registry
File "/home/abdulrahman/odoo/odoo-15.0/odoo/modules/graph.py", line 10, in
import odoo.tools as tools
File "/home/abdulrahman/odoo/odoo-15.0/odoo/tools/init.py", line 8, in
from . import pdf
File "/home/abdulrahman/odoo/odoo-15.0/odoo/tools/pdf.py", line 18, in
from odoo.tools.misc import file_open
File "/home/abdulrahman/odoo/odoo-15.0/odoo/tools/misc.py", line 35, in
import babel
File "/home/abdulrahman/.local/lib/python3.10/site-packages/babel/init.py", line 20, in
from babel.core import UnknownLocaleError, Locale, default_locale, \
File "/home/abdulrahman/.local/lib/python3.10/site-packages/babel/core.py", line 14, in
from babel import localedata
File "/home/abdulrahman/.local/lib/python3.10/site-packages/babel/localedata.py", line 17, in
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/init.py))
This is the errors i want the solutions for it.
Hi I'm not sure if it's the proper solution but I experienced some difficulty with my python version and when I downgraded the version (to py3.9) it worked. You can Try it too. Also I suggest to check your launch.json configurations and make sure that all the paths and names have been set correctly.

import error in python user interface, thony and pycharm

while importing tensor flow as import tensorflow it raise an error,:
import tensorflow
Traceback (most recent call last):
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_init_.py", line 41, in
from tensorflow.python.tools import module_util as module_util
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python_init.py", line 40, in
from tensorflow.python.eager import context
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\context.py", line 35, in
from tensorflow.python import pywrap_tfe
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Amit Maurya\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
I've had similar issue but I'm not sure if the solution is applicable here, too. Anyway, I'd suggest to install the MS Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 if you haven't done it yet.
You can find the redistributable here.

How to use the ibm_boto3 in python

Who has the same problem?
I want to store data in cos, but cannot use the ibm_boto3 on my machine.
To be sure to check with a sample, I used the code from the sample from this ibm-cos-sdk github.
Installed
pip3 freeze
backports.functools-lru-cache==1.5
botocore==1.12.28
docutils==0.14
futures==3.1.1
ibm-cos-sdk==2.3.2
ibm-cos-sdk-core==2.3.2
ibm-cos-sdk-s3transfer==2.3.2
-e git://github.com/boto/jmespath.git#1c9c35cf681b6605d8629e5ce8865221a4fd2a30#egg=jmespath
mock==1.3.0
nose==1.3.3
pbr==5.0.0
python-dateutil==2.7.3
s3transfer==0.1.13
six==1.11.0
urllib3==1.23
Here is my cli result and as you can see the ibm_boto3 is not found.
python3 test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
import ibm_boto3
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_boto3/__init__.py", line 16, in <module>
from ibm_boto3.session import Session
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_boto3/session.py", line 27, in <module>
import ibm_botocore.session
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_botocore/session.py", line 37, in <module>
import ibm_botocore.credentials
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_botocore/credentials.py", line 36, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Yeah, it looks like requests somehow fell out of the requirements file in the latest release. The team is patching it and will release an update soon.
In the meantime, you can manually install the package in your environment with pip3 install requests or by manually adding it to the requirements.txt file:
echo "requests==2.18.0" >> path/to/requirements.txt

Docker-compose ps error

I am new to docker-compose and getting the following error when I type in docker-compose ps.
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 7, in <module>
from compose.cli.main import main
File "/Library/Python/2.7/site-packages/compose/cli/main.py", line 20, in <module>
from ..bundle import get_image_digests
File "/Library/Python/2.7/site-packages/compose/bundle.py", line 14, in <module>
from .service import format_environment
File "/Library/Python/2.7/site-packages/compose/service.py", line 37, in <module>
from .parallel import parallel_execute
File "/Library/Python/2.7/site-packages/compose/parallel.py", line 10, in <module>
from six.moves import _thread as thread
ImportError: cannot import name _thread
Docker-compose is written by python. It seems that you miss some python packages. You can refer to the following page of how to fix the python lib issue.
Matplotlib issue on OS X ("ImportError: cannot import name _thread")
Alternatively, you can try to install docker-compose as a container, the docker container contains appropriate environment for docker-compose.
https://docs.docker.com/compose/install/#install-as-a-container

google-cloud-storage library from nosetests using testbed

I have google-cloud-storage pip installed into a lib directory and vendored in. It's running just fine locally during development of my python appengine app. However, when trying to run unit tests via nose and testbed I'm getting "The 'google-cloud-core' distribution was not found and is required by the application". Here is the stack:
Traceback (most recent call last):
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/jason/dev/gain-data/data/storage/__init__.py", line 4, in <module>
from google.cloud.storage import Blob, Client
File "/Users/jason/dev/gain-data/lib/google/cloud/storage/__init__.py", line 42, in <module>
from google.cloud.storage.batch import Batch
File "/Users/jason/dev/gain-data/lib/google/cloud/storage/batch.py", line 30, in <module>
from google.cloud.storage.connection import Connection
File "/Users/jason/dev/gain-data/lib/google/cloud/storage/connection.py", line 17, in <module>
from google.cloud import connection as base_connection
File "/Users/jason/dev/gain-data/lib/google/cloud/connection.py", line 31, in <module>
get_distribution('google-cloud-core').version)
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 557, in get_distribution
dist = get_provider(dist)
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 431, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 968, in require
needed = self.resolve(parse_requirements(requirements))
File "/Users/jason/dev/gain-data/venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 854, in resolve
raise DistributionNotFound(req, requirers)
DistributionNotFound: The 'google-cloud-core' distribution was not found and is required by the application
Any thoughts?
I had the same issue with google-cloud-translate, I was forced to also install the package "globally", i.e. pip install google-cloud-translate.
After struggling a lot with this same issue I found out that the error was because the vendor pip lib wasn't in the PYTHONPATH before calling the nosetests.
Try adding the vendor lib to the PYTHONPATH and then run the tests.
export PYTHONPATH="$(HOME)/Projects/myproject/pip_lib:$$PYTHONPATH"; \
nosetests .