System info:
Ubuntu 16.04
Python 3.6.5 in anaconda3/envs/testcaffe/bin/python3
Anaconda3 4.5.2
CPU only
I installed Caffe2 by conda install -c caffe2 caffe2
for python to find onnx i set the PYTHONPATH to /home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site-packages/caffe2/python
importing onnx import onnx in python works fine, but when i tried to run converter script provided in tutorial i get this:
File "converter.py", line 2, in <module>
import caffe2.python.onnx.frontend
File "/home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site-
packages/caffe2/python/onnx/frontend.py", line 22, in <module>
from onnx import (defs, checker, helper, numpy_helper, mapping,
File "/home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site-
packages/caffe2/python/onnx/helper.py", line 9, in <module>
from onnx.backend.base import namedtupledict
File "/home/username/WorkStuff/anaconda3/envs/testcaffe/lib/python3.6/site-
packages/caffe2/python/onnx/backend.py", line 33, in <module>
from onnx import checker, GraphProto, TensorProto, AttributeProto,
ModelProto
ImportError: cannot import name 'checker'
checker.h is located in /home/username/WorkStuff/anaconda3/envs/testcaffe/include/onnx
although there are no ...Proto files in my testcaffe directory
if i just run Python and write import onnx.checker it returns ModuleNotFoundError: No module named 'onnx.checker'
seems like onnx cant import any of its modules
Is there anything i simply miss or don't understand?
Thank you for your help
Apparently the newer version of ONNX does not have these files.
I tested ONNX v1.0.0 and everything is there.
Please install it by using: conda install -c willyd onnx
This works on linux x64, but I'm not sure how to fix on other systems.
Related
I use Pydev and try to load numpy in my script. I installed Anaconda to be able to use it, following the Anaconda user guide concerning how to set it up as interpreter in Pydev.
I have tried installing Anaconda both with and without adding it to PATH (the recommended version is without). In both cases numpy shows up as an installed package in Pydev:
However, when I run my script I receive the following error:
File "Z:\Path\To\My\file.py", line 2, in <module>
import numpy as np
File "C:\Users\(username)\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\(username)\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
I also noticed that in the manual from anaconda, in the shown picture a lot more library folders are added than what I am presented with. I couldn't find a list of those, though. Running numpy from the Anaconda prompt works fine.
Any ideas would be appreciated!
I'm trying to run a Python script from the Windows shell, but when I do
python path\to\file\script.py
I get an error "DLL load failed: The specified module could not be found" and it traces back to the line where I import numpy.
C:\Users\Admin>python path\to\file\script.py
Traceback (most recent call last):
File "path\to\file\script.py", line 8, in <module>
import numpy as np
File "C:\Users\Admin\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\Admin\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
The weird part is that when I run it in an editor like Spyder, numpy imports just fine. Can someone help me?
Thanks
It's fixed Anaconda path issue. Check your %PATH% if it's correctly defined.
Source: https://github.com/numpy/numpy/issues/12957
This is a common problem when installing python packages, mainly in windows.
Numpy and other packages have bindings to C++ code that require some special dependencies.
Rather than trying to get the dependencies exactly right for compiling the package, you can use a precompiled "wheel" file from one of several sources.
I use Chris Gholke's site
download the .whl file and install using
pip install directory/path/package.whl
edit: and as a note, the python environment you access from powershell or cmd is different from the anaconda environment in spyder. One of the differences between conda and pip is that conda installed precompiled packages while pip does not.
I solved my issues with Numpy DLL load issues by replacing Anaconda3 with WinPython.
I've been working on learning artificial intelligence and how to code with Python.I was working on a project and I decided to update some packages of Python which were not new to work on then something happened and I can't compile my codes.I deleted Anaconda3 and set it up again but not worked. I've been seeing this problem which I wrote as a topic.If someone helps me,I would be appriciated to get some help.
>>> import tensorflow as tf
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\__init__.py", line 63, in <module>
from tensorflow.python.framework.framework_lib import * # pylint: disable=redefined-builtin
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\framework\framework_lib.py", line 104, in <module>
from tensorflow.python.framework.importer import import_graph_def
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\framework\importer.py", line 32, in <module>
from tensorflow.python.framework import function
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\framework\function.py", line 36, in <module>
from tensorflow.python.ops import resource_variable_ops
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 35, in <module>
from tensorflow.python.ops import variables
File "C:\Users\AliGalip\Anaconda3Yeni\lib\site-packages\tensorflow\python\ops\variables.py", line 40, in <module>
class Variable(checkpointable.CheckpointableBase):
AttributeError: module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase'
The same question has been posted as a GitHub issue. In particular, the solution suggested by #allanlavoie is likely relevant here as well:
Sounds like a half-updated version of TensorFlow. Could you try removing TensorFlow entirely (e.g. pip uninstall tf-nightly or whichever package is installed), making sure import tensorflow fails, then reinstalling?
Since it is apparent from your question that you're using Anaconda to manage your Python environments, if the above fails to solve your problem, you can try to install TensorFlow in a clean conda environment as follows:
Create a new environment through conda create --name tftest. (You can replace tftest with e.g. the name of your current project.)
Activate that new environment through activate tftest (or source activate tftest if you happen to be using MSYS2's bash, or something similar to that).
Install TF into this environment through conda install tensorflow.
Ensure that you're in the right environment through where python (which should produce a path containing "tftest").
Run Python through python.
import tensorflow as tf in a shell in that environment.
Since you are using PyCharm (cf. the comments for this answer), you will then want to set up PyCharm for using this new environment instead. Indeed, using a new environment for every project, while disk space-intensive, is a good way of avoiding dependency issues for these rather dependency-heavy numerical packages.
This is error may be dues to the version of the tensorflow, your code is not compatible with the latest version of the tensor flow. Try installing older version of Tensorflow such as 1.14.0 or 1.7.0 it worked for me.
pip3 uninstall tensorflow
And then:
pip3 install --upgrade "tensorflow==1.15"
I am attempting to train a TensorFlow model in Windows 10 using these steps: https://github.com/tensorflow/models/tree/master/attention_ocr#requirements
I have installed virtualenv for Windows (following this example)
The source command is not recognized by Windows. Are the additional steps to the virtualenv command required for Windows, or is there an alternative usage of the source command?
Note that the subsequent pip install commands worked (pip, tensorflow_gpu), but when I attempt to train using train.py I get the following error:
File "train.py", line 27, in <module>
from tensorflow.contrib.tfprof import model_analyzer
ImportError: cannot import name 'model_analyzer'
It looks like your virtualenv is configured correctly, but the code you are trying to use imports tf.contrib.tfprof, which is not currently (as of TensorFlow 1.2) supported on Windows.
However, since tf.contrib.tfprof is only used to provide profiling information, you should be able to run the code by manually removing the following line from train.py:
Line 27: from tensorflow.contrib.tfprof import model_analyzer
...and passing the flag --show_graph_stats=false when running the script.
In Windows, I created a Conda virtual environment with the command
conda create -n test python=2.7 pandas scipy matplotlib numpy
Once it is created, I activated the virtual environment and went into a python interpreter. When trying to import numpy, I get the following error:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\lib\__init__.py", line 8,
in <module>
from .type_check import *
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\core\__init__.py", line 14, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
Any ideas what is going on here? Thanks!
Uninstall and install numpy again.
pip uninstall numpy
pip install numpy
Then try import again, it should work. That is what I did
Unlike #Rafael, for me, libiomp5md.dll wasn't the issue. I installed Dependency Walker to investigate what was going on. Even though the dll versions were different, but Dependency Walker said it was okay.
What was wrong though, was that mkl_intel_thread.dll had warnings (red icon). If you're using Win 8++, ignore the api-win and ext-ms issues as Dependency Walker wasn't updated for new Windows versions and doesn't recognise Windows new APIs.
My solution is to copy all mkl_*.dlls from the former to the latter:
\Anaconda2\Library\bin
\Anaconda2\Lib\site-packages\numpy\core
I was able to import numpy and sklearn after that.
It seems the proper way to fix this is to do:
conda install msvc_runtime
If you are in a virtual environment, add this package there.
For my case, I have also the import numpy DLL error in anaconda3, and Decrayer (Nov 28) provided the best solution: I had the same error except for Anaconda3: just added the path \Anaconda3\Library\bin to your Windows 10 path variable and then it worked.
I have been trying to install anaconda3.7.1 or 3.7.0 without luck, going to full length of restarting the PC after the key steps to make sure the DLL is no longer in use in memory. Ultimately, thanks to decrayer, now numpy works for me!
For me this was solved by adding the following paths to my system path variable.
C:\Users\UserName\Anaconda3\
C:\Users\UserName\Anaconda3\bin
C:\Users\UserName\Anaconda3\Scripts
C:\Users\UserName\Anaconda3\Library\mingw-w64\bin (not strictly necessary)
C:\Users\UserName\Anaconda3\Library\bin
Before adding them explicitly in the system path variable, you can perform a test by adding these paths temporarily:
base_path = r"C:\Users\UserName\Anaconda3"
path = os.pathsep.join([os.path.join(base_path, i) for i in [r"", r"bin", r"Scripts", r"Library\mingw-w64\bin", r"Library\bin"]])
os.environ["PATH"]+=os.pathsep+path
Thanks to this post on PyCharm support.
For the record, I had the same error here (Python 3.5 64-bit on Windows 10), and this page helped me find the solution. The problem was a conflict with libiomp5md.dll, which existed on two locations:
C:\Windows\System32\libiomp5md.dll
C:\Anaconda3\Library\bin\libiomp5md.dll
Python was trying to use the version in System32 folder, which was an old version. I removed it (renamed) and now it uses the correct version, on Anaconda3 folder, and now I can import numpy without the import error.