Python can't find torch module - python

I'm simply trying to run a .py file, and not sure why it can't find the torch module. I am pretty sure all modules are up to date, and I can see the torch module in my lib/ folder...
Traceback (most recent call last):
File "ptb-lm.py", line 86, in <module>
import torch
File "C:\Users\Public\Anaconda3\lib\site-packages\torch\__init__.py", line 80, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
To be honest I'm still confused as to when / why use conda or pip but I did check that both were up to date!

Try using anaconda to install torch.
Use this link to download https://pytorch.org/get-started/locally/

Related

ImportError: DLL load failed while importing _remap

I want to open an image in python script but when importing skimage.io I get the following error. I have installed pip install scikit-image several times but I always get this error. Can anyone help me?
Traceback (most recent call last):
File "C:/Users/Admin/Desktop/BA Code/PSR-Staining/main.py", line 9, in
import skimage.io
File "C:\Users\Admin\Desktop\BA Code\PSR-Staining\venv\lib\site-packages\skimage_init_.py", line 127, in
from .util.dtype import (img_as_float32,
File "C:\Users\Admin\Desktop\BA Code\PSR-Staining\venv\lib\site-packages\skimage\util_init_.py", line 17, in
from ._map_array import map_array
File "C:\Users\Admin\Desktop\BA Code\PSR-Staining\venv\lib\site-packages\skimage\util_map_array.py", line 2, in
from ._remap import _map_array
ImportError: DLL load failed while importing _remap: The given module is not found.
Can you try pip install msvc-runtime? See discussion here.

Tensorflow: ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found

I have been stuck on this error (for importing tensorflow) for a while, I looked on various different pages and didn't find a solution that helped. I tried installing vs 2015 as said on the internet, but that didn't work. I have downloaded python 3.8.0 rather than 3.8.2, but i still get the error. Please Help!
windows 10, latest version of tensorflow
>>> import tensorflow
Traceback (most recent call last):
File "C:\...\Python\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\...\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\...\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\...\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\...\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\...\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\...\Python\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: The specified module could not be found.
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 found a solution to my question:
Using pip:
There are system requirements that I won't bother talking about all of them as they could be found on the tensorflow website, though the 3 problems I had were that:
I didn't install Microsoft Visual C++ Redistributable for Visual
Studio 2015, 2017 and 2019.
Long paths weren't enabled
So just following a youtube tutorial didn't finish the problem. I had to download it based on the way on tensorflow's website.
Create a virtual environment in python. For the creation of a virtual environment, you need virtualenv library.
pip install virtualenv
After installing create your virtual environment.
command - virtualenv "NAME-OF-ENVIRONMENT"
eg
virtualenv myenv
This will create a directory called myenv. To activate the virtual environment you have go inside the myenv/scripts folder, open a cmd prompt and type activate.
eg
cd myenv/Scripts
activate
Get out of the Scripts folder
cd ../..
Now install TensorFlow.
pip install tensorflow
Note: Always create a virtual environment when working in any project and keep your python package clean. You can delete these environments if they become corrupt or stop working correctly due to any reason, without and fear.

"from numpy.core._multiarray_umath import" throws error "DLL load failed: The specified module could not be found."

I am testing my numpy installation. In Python prompt I tried writing import numpy. However it is giving the below error. I am using Anaconda. I had installed numpy using conda command conda install numpy
Python version 3.7.7
numpy version 1.18.1
OS is Win 10
Log:
>>> import numpy
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
from . import overrides
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\ProgramData\Anaconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.

DLL files error in using pytorch

I add pytorch via pip installation and now I'm trying to use it, but have this dll error:
Traceback (most recent call last):
File "F:/Python/Projects/1.py", line 2, in <module>
import torch
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\__init__.py", line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
I install msvcp71 and msvcr71 dll files but it's not worked!
You can use Dependency Walker to find out which dependency of that DLL might be missing. Use it to open the Python extension file that's failing to load. The file name should be something like:
C:\Users\Saeed\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\_C.pyd
Another common cause is a DLL for Python 64-bit while using Python 32-bit or vice-versa. But you installed with pip so it should be OK. Nevertheless, it's a good idea to verify this is not the case.

Error: How to import method from one file to other in a same directory

I'm using python version 3.6.1
I want to use method of one python file to another located in a same directory. I have used from utils import wit_response in app.py file. And when I compile it this shows an error:
Traceback (most recent call last):
File "app.py", line 4, in
from utils import wit_response
File "E:\Study\Python\fbmessengerbot\utils.py", line 1, in
from wit import Wit
ModuleNotFoundError: No module named 'wit'
In utils.py file I'm using from wit import Wit. The wit package i have already installed.
How can i resolve this.
Thanks in advance.
If you are using a Virtual environment do pip freeze and check whether "wit" package is installed or not.
If "wit" is installed open ipython and check whether you can import the "wit" package.
If "wit" is not imported in ipython check if any dependency packages are need for "wit".

Categories