Dll load failed - tensorflow

My code is this, this is a test code from a youtuber:
import numpy as np
import cv2 as cv
from tensorflow.keras import datasets, layers, models
import mathplotlib.pyplot as plt
(training_images, training_labels), (testing_images,
testing_labels) = datasets.cifar10.load_data()
training_images, testing_images = training_images/255, training_labels/255
class_names = ['Plane', 'Car']
for i in range(16):
plt.subplot(4, 4, i+1)
plt.xticks([])
plt.yticks([])
plt.imshow(training_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[training_labels[i][0]])
plt.show()
And this is what happens when I run it:
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "image classification test.py", line 3, in <module>
from tensorflow.keras import datasets, layers, models
File "C:\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
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.
I installed tensorflow from both anaconda and pip and same error happens, I cant seem to find a solution on this one so please help me out

The optimistic quick check, make sure you have the latest Visual C++ DLL installed.
I just encountered this myself; in my case the system I was trying to run Tensorflow on uses a G3220. According to Issue #39007 TensorFlow requires AVX extensions, which my CPU does not support. You can do a quick check to see if your processor supports AVX extensions by searching for it on the Intel Ark (Link to my G3220 which does not support AVX and a link to a i7-4790 that does support AVX. I suspect this is the same problem that you are having.
You may be able to compile TF yourself or use a build someone else made to run without AVX (see: Run TensorFlow 2.0 on CPU without AVX). In my case, I was able to use the unofficial TF python build referenced in this Stack Overflow answer to install TF 2.4 from here https://github.com/fo40225/tensorflow-windows-wheel.
Intel Ark i7-4790 AVX Example Image

Related

Tensorflow - ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed

I am struggling to utilise TensorFlow within Jupyter notebook. I have installed TensorFlow via Anaconda Prompt (running as admin). But when I go to call it in my notebook I get the following error string (sorry this is long).
Any help or thoughts would be welcomed here - should I run a full uninstall and try again?
kind regards
Jack
I am running:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
The error message is as follows (there are a number of others but this is the first and the rest have similar issue):
Traceback (most recent call last):
File "C:\Users\jjcon\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\jjcon\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\jjcon\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\jjcon\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\jjcon\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
You have to install the Microsoft Visual C++ 2015-2019 Redistributable (x64) from here.
If you are facing any other issues possible reasons are
Your CPU does not support AVX2 instructions
Your CPU/Python is on 32 bits
There is a library that is in a different location/not installed on your system that cannot be loaded.
Please refer tested build configurations for windows CPU and GPU.

PermissionError: [Errno 1] Operation not permitted while using Selenium with Pythonista on iOS

I want to create a program in pythonista that can control the web browser. I know Selenium is the best for this but I have tried it on pythonista for my iOS iPhone and I get an error.
This is the code:
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('http://www.yahoo.com')
Here is the error:
PermissionError: [Errno 1] Operation not permitted
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/A2EBDF28-CB6C-4190-8199-7406AA3821A3/Pythonista3/Documents/selen.py", line 3, in <module>
browser = webdriver.Chrome()
File "/private/var/mobile/Containers/Shared/AppGroup/A2EBDF28-CB6C-4190-8199-7406AA3821A3/Pythonista3/Documents/site-packages-3/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/private/var/mobile/Containers/Shared/AppGroup/A2EBDF28-CB6C-4190-8199-7406AA3821A3/Pythonista3/Documents/site-packages-3/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/var/containers/Bundle/Application/24DD2A57-320E-4E21-9BE2-7C3605830DE0/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 708, in __init__
restore_signals, start_new_session)
File "/var/containers/Bundle/Application/24DD2A57-320E-4E21-9BE2-7C3605830DE0/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 1261, in _execute_child
restore_signals, start_new_session, preexec_fn)
PermissionError: [Errno 1] Operation not permitted
This error message...
PermissionError: [Errno 1] Operation not permitted
...implies that the ChromeDriver was unable to create a desired new resource e.g. logfile while initializing a new WebDriver and Web Client session.
As per the discussion Pythonista - Limitations due to iOS following are some of the limitations while using Pythonista :
No fork/exec for new processes. Impacts the subprocess module.
Due to missing fork, no full cleanup of process resources (memory, threads, file handles).
No file access outside of application directory.
No /dev/null and other special files.
Limited processing power of devices (compared to typical PC/Mac).
Process usually is stopped/killed after a while.
An simple example is as follows :
>>> import subprocess
>>> subprocess.call(["ls", "-l"])
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Bundle/Application/8C59C68D-71BF-4CBB-90F8-373A1752DEE1/Pythonista.app/pylib/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/private/var/mobile/Containers/Bundle/Application/8C59C68D-71BF-4CBB-90F8-373A1752DEE1/Pythonista.app/pylib/subprocess.py", line 711, in __init__
errread, errwrite)
File "/private/var/mobile/Containers/Bundle/Application/8C59C68D-71BF-4CBB-90F8-373A1752DEE1/Pythonista.app/pylib/subprocess.py", line 1205, in _execute_child
self.pid = os.fork()
OSError: [Errno 1] Operation not permitted
What's wrong in your usecase
There can be 2 issues as follows :
When you invoke the following line of code :
browser = webdriver.Chrome()
The ChromeDriver tries to create/modify/access the scoped_directory within the file system. For example on Windows OS :
"chromedriverVersion": "2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73)",
"userDataDir": "C:\\Users\\username\\AppData\\Local\\Temp\\scoped_dir5188_12717"
Possibly ChromeDriver is unable to perform this task/method/functionality.
Again when you invoke the following line of code :
browser = webdriver.Chrome()
As per selenium.webdriver.chrome.webdriver ChromeDriver tries to create a logfile within the file system as per the constructor as follows :
class selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', port=0, options=None, service_args=None, desired_capabilities=None, service_log_path=None, chrome_options=None)
Possibly ChromeDriver is unable to perform this task/method/functionality,
Due to the above mentioned reasons you are seeing the error :
PermissionError: [Errno 1] Operation not permitted
Solution
Incase of any of the above mentioned cases the solution would be to restrict the access/creation of the resources within the application directory only.

Tensorflow could not initialize the libcurl library on Mac OS

I have build up the WebAPP of this Project on Mac OS using conda and tensorflow v0.12.1. It work so well still I try to train, tensorflow show this error message:
W tensorflow/core/platform/cloud/google_auth_provider.cc:151] All
attempts to get a Google authentication bearer token failed, returning
an empty token. Retrieving token from files failed with "Failed
precondition: Could not initialize the libcurl library. Please make
sure that libcurl is installed in the OS or statically linked to the
TensorFlow binary.". Retrieving token from GCE failed with "Failed
precondition: Could not initialize the libcurl library. Please make
sure that libcurl is installed in the OS or statically linked to the
TensorFlow binary.".
Logs:
2018-04-03 09:33:49,154 - candysorter.views.api - INFO - === Start training: id=9120093671565748, session=20180403_093211_9120093671565748 ===
2018-04-03 09:33:49,154 - candysorter.views.api - INFO - Creating labels file: job_id=candy_sorter_20180403_093211_9120093671565748
2018-04-03 09:33:49,184 - candysorter.views.api - ERROR - Unexpected error.
Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 101, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 337, in train
candy_trainer.create_labels_file(job_id, labels)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/train.py", line 76, in create_labels_file
f.write(json.dumps(labels, separators=(',', ':')))
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 150, in __exit__
self.close()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 182, in close
pywrap_tensorflow.Set_TF_Status_from_Status(status, ret_status)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
FailedPreconditionError: Could not initialize the libcurl library. Please make sure that libcurl is installed in the OS or statically linked to the TensorFlow binary.
I use TF1.7.0 instead of TF0.12.1, and fix this problem. But I still don't know what happen in TF0.12.1.

Selenium webdriver.Firefox() is not callable

I hope this is something simple, it feels like it. But it is beyond me at the moment.
I am a new starter with Selenium, I want to automatically extract information from a website and this seems a good method.
For a change I have started doing this on Windows 10 and I want program in Python so I am using PyCharm. I have installed Selenium using pip install selenium and if I use the python command line shell with the following:
from selenium import webdriver
driver = webdriver.Firefox()
I get the following error message:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Damo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 81, in __init__
self.binary, timeout)
File "C:\Users\Damo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 51, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "C:\Users\Damo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "C:\Users\Damo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 98, in _wait_until_connectable
raise WebDriverException("The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
When I type the same within PyCharm the IDE tells me that this term webdriver.Fiefox results in Firefox is not callable
Have I failed to install something?
>
Not meant as a silly reaction, but do you have the latest version of Firefox installed on your machine?

ImportError: No module named date_capnp

While trying to understand nupic minecraft demo code. I am running nupic_client.py from pycharm IDE. Python version is 2.7.8 on Mac OS with nupic dowloaded as package version 0.2.8
On running nupic_client.py following error occurs ImportError: No module named date_capnp
Any help is appreciated.
Stack Trace:
File "/Users/msghotra/Sandbox/CodeHub/datascience/workspace/nupic_minecraft/nupic_client.py", line 5, in <module>
from nupic.frameworks.opf.modelfactory import ModelFactory
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nupic/frameworks/opf/modelfactory.py", line 32, in <module>
from clamodel import CLAModel
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nupic/frameworks/opf/clamodel.py", line 44, in <module>
from nupic.encoders import MultiEncoder, DeltaEncoder
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nupic/encoders/__init__.py", line 24, in <module>
from date import DateEncoder
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nupic/encoders/date.py", line 28, in <module>
from nupic.encoders.date_capnp import DateEncoderProto
ImportError: No module named date_capnp
I believe you mean nupic==0.2.3, since 0.2.8 isn't out yet. This should be fixed with https://github.com/numenta/nupic/pull/2231. More details are available in the issue you referenced (the direct link is https://github.com/numenta/nupic/issues/2166). Hope this helps!
EDIT This should now be resolved in nupic==0.2.6