Spacy_DLL load failed while importing nn_parser - python-3.x

I am trying to download the french module for Spacy with the command python -m spacy download fr_core_news_md , but it get error:
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 143, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\__init__.py", line 12, in <module>
from . import pipeline
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\spacy\pipeline\__init__.py", line 4, in <module>
from .pipes import Tagger, DependencyParser, EntityRecognizer, EntityLinker
File "pipes.pyx", line 1, in init spacy.pipeline.pipes
ImportError: DLL load failed while importing nn_parser: The specified module could not be found.
How to fix it?
Python 3.8.2 (64 bit) on Windows 10*64
Thank you!

I managed to fix this error by installing Visual C++ redist on my Windows machine.
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

I also managed to fix this by installing the MS VC redist package. If you use, chocolately: https://chocolatey.org/packages/vcredist140
choco install vcredist140

Related

How do I fix this 'ModuleNotFoundError: No module named 'pip._internal.models.target_python'?

I am new to python and was testing some things out I had seen online.
from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://techwithtim.net")
But I get the following error message:
Traceback (most recent call last):
File "C:\Users\absol\PycharmProjects\pythonProject\test.py", line 2, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Process finished with exit code 1
I have already successfully used pip install selenium and other variations which after trying to repeat them they inform me that requirements are already met. IDLE will tell me the selenium version when I ask for it.
I then tried the "Python Packages" tab to manually install selenium but it returns the following error message:
File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3\plugins\python-ce\helpers\packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\cmdoptions.py", line 29, in <module>
from pip._internal.models.target_python import TargetPython
ModuleNotFoundError: No module named 'pip._internal.models.target_python'
And it suggests to run the following:
(venv) C:\Users\absol>C:\Users\absol\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Program Files/JetBrains/PyCharm Community Edition 2022.3/plugins/python-ce/helpers/packaging_tool.py install selenium
Which returns this:
(c) Microsoft Corporation. All rights reserved.
C:\Users\absol>C:\Users\absol\PycharmProjects\pythonProject\venv\Scripts\activate.bat
(venv) C:\Users\absol>C:\Users\absol\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Program Files/JetBrains/PyCharm Community Edition 2022.3/plugins/python-ce/helpers/packaging_tool.py install selenium
C:\Users\absol\AppData\Local\Programs\Python\Python311\python.exe: can't open file 'C:\\Program': [Errno 2] No such file or directory
(venv) C:\Users\absol>pip install selenium
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\absol\PycharmProjects\pythonProject\venv\Lib\site-packages\pip\_internal\cli\cmdoptions.py", line 29, in <module>
from pip._internal.models.target_python import TargetPython
ModuleNotFoundError: No module named 'pip._internal.models.target_python'
*Note: I went ahead and tried pip install selenium again just because I saw the (venv)
At this point I just don't know where I should be looking. I thought maybe I just don't know how to deal with PyCharm virtual environments and should change to a different script writer. I would be open to that, or just a link to a comprehensive guide for me to read over how to fix PyCharm.
Any help or direction to some kind of video media is appreciated.
Edit/Update: I am able to run the code through IDLE and Jupyter. Although still get a "deprecation" message:
driver = webdriver.Chrome(PATH)
Try this commmand.
python -m pip install --upgrade pip

Q: How to fix the missing dependancies in pyzbar

I am currently using spyder via anaconda with python 3.8.5 on windows 10 and I am trying to use the pyzbar package to make a barcode reader. When I try to run the script I get this error message when trying to run from pyzbar.pyzbar import decode and from pyzbar import pyzbar:
Traceback (most recent call last):
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 58, in load
dependencies, libzbar = load_objects(Path(''))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<ipython-input-1-95ae0761f4b5>", line 1, in <module>
from pyzbar.pyzbar import decode
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 139, in <module>
zbar_version = zbar_function(
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
When trying to run just import pyzbar it will compile, but it will not be able to access any of the function. When I try I get this message:
Traceback (most recent call last):
File "<ipython-input-3-26272af93b8a>", line 1, in <module>
pyzbar.pyzbar.decode()
AttributeError: module 'pyzbar' has no attribute 'pyzbar'
I have looked up the documentation for pyzbar on github which states "The zbar DLLs are included with the Windows Python wheels", but have not found this anywhere. The closest to "Windows Python wheels" I have found is the wheel package which does not contain any information about pyzbar.
Any advice on how to fix this?
Visit https://pypi.org/project/pyzbar/#files to download pyzbar-0.1.8-py2.py3-none-win_amd64.whl.
You can find all the DLL files inside the wheel package.
I have just encountered this problem.
If your OS & python are x64 version, it's just because of lack of vc 2013 x64 runtime.
You can find Visual C++ Redistributable Packages for Visual Studio 2013 here
download & install.
I was facing similar issue just installed Visual
C++ 64 bit version on my computer and restarted. Choose between vcredist_x86.exe or vcredist_x64.exe based on your machine.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784. Hope this solves your issue as well.

Python 3.8.1: ModuleNotFoundError: No module named '_pywrap_tensorflow_internal' - Is tensorflow only supported up to 3.7?

I am using Python 3.8.1 on Windows 10 and am trying to install TensorFlow.
I have tried many methods to install it, but I keep getting the following error upon importing TensorFlow. This time, I installed it using
conda install -c conda-forge tensorflow
Here is the stack trace:
Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Program Files (x86)\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "deep_versions.py", line 6, in <module>
import keras
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\backend\__init__.py", line 1, in <module>
from .load_backend import epsilon
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\backend\load_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Program Files (x86)\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
What I have done to try to fix it: I have looked at other similar questions on here but they have been for older versions of Python. I have also looked at this GitHub post but could not resolve the issue.
I checked the TensorFlow site for Python version compatability but the latest update that I could find was a few months ago, saying that TensorFlow only supports up to Python 3.7 (https://github.com/tensorflow/tensorflow/issues/33374) Is this still the case and do I need to downgrade Python in order to use TensorFlow?
Please let me know if there is any more information I should provide (I'm still learning how to correctly ask questions here). Thank you.
Edit: I created a conda environment with Python 3.7 and I did not get the same error and importing TF seems to be working fine now. It seems that Python 3.8 is still not yet supported, so this may have been the problem.
Per the installation documents, only Python 3.5-3.7 are supported. https://www.tensorflow.org/install
I think it has to do with the version of python or TensorFlow and You should change versions of either Python or Tensorflow, as these 2 versions you are using are not compatible. You could downgrade to Python3.6 or try Tensorflow>=1.13.1 which supports Python 3.7. it should work hopefully.
Well for me, i managed to fix it by creating a venv by using conda create -n <venv name> python=3.6. Important to note that the python version specified needs to be 3.6. Then, using the same command just the difference is that i used tensor-gpu instead conda install -c conda-forge tensorflow-gpu. Note that my python versio on my machine is 3.7.8, but i guess any versions from 3.5-3.8 should be fine. Hope it still helps someone in the future!

Unable to import "eml_parser" module in Python

I am unable to import "eml_parser" module in Python.
I am running Windows 10, Python37 and Anaconda 5.3 (all 64 bit)
The installation docs are at this link: https://pypi.org/project/eml-parser/
I did find the following suggestion from https://github.com/pymedusa/Medusa/issues/1843 but I have not tried it yet. To update the init file as suggested requires administrative rights and I wasn't exactly sure how to open the file as an administrator and save it that way. It seem to make more sense to ask the question before getting too far into editing files. Note line 362 in the quote below would be the equivalent to line 356 on my error message.
Suggestion from https://github.com/pymedusa/Medusa/issues/1843
"If you are using a special version of Python [like Anaconda] and you can't fix it. Navigate to line 362 of lib/ctypes/init.py and change it to:
self._handle = _dlopen(str(self._name), mode)"
From Command Prompt, I get the following error message:
>>> import eml_parser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python37\lib\site-packages\eml_parser\__init__.py", line 8, in <module>
from . import eml_parser
File "C:\Program Files\Python37\lib\site-packages\eml_parser\eml_parser.py", line 63, in <module>
import magic
File "C:\Program Files\Python37\lib\site-packages\magic.py", line 23, in <module>
_libraries['magic'] = _init()
File "C:\Program Files\Python37\lib\site-packages\magic.py", line 20, in _init
return ctypes.cdll.LoadLibrary(find_library('magic'))
File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
Im not sure how it fixes this but I tried
pip install python-magic
pip install eml_parser
And got this working on Windows 10
https://github.com/GOVCERT-LU/eml_parser/issues/14

Cannot use most python apps after updating to Ubuntu 18.04

After updating to Ubuntu 18.04 LTS I can no longer use most Python apps including pip (to install or uninstall). I get the following error in command-line:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module> load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 572, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2755, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2408, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2414, in resolve
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
After Googling the errors it appears that the version of pyopenssl is out of date, but I've tried to manually download an installpyopenssl18 through a TGZ file or through easy_install and neither have worked.
I cannot install/uninstall via pip because I get the above error. Any suggestions? I'd like to avoid having to reinstall Python or even the OS itself.
After trying the manual install of pyopenssl 18 again I noticed the path it was installing to: /usr/local/lib/python2.7/dist-packages
So I went digging in that directory and saw a folder called:
OpenSSL
which was referenced in the error. I renamed this folder and re-installed pyopenssl and the error is cleared. I don't have any issues accessing HTTPS sites so it is possible this is a deprecated module replaced by pyOpenSSL?

Resources