I installed Anaconda on my machine yesterday and installed the Anaconda Extention Pack in VSC, when I try this:
Code:
import numpy as ny
I get this error:
Traceback (most recent call last):
File "e:/Python/Testing/VSC with Anaconda/packagetest.py", line 1, in <module>
import numpy as ny
File "E:\Anaconda\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "E:\Anaconda\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.
Please help me fix this.
A very common reason for this error is that the conda environment hasn't been properly activated. This can be done by either using the "Anaconda prompt" or by e.g. starting the cmd shell and then running C:\users\user_name>conda activate. This will change the prompt to (base) C:\users\user_name> and add serveral Anaconda subfolders to the PATH. Then Python should be started from there via (base) C:\users\user_name> python. Without activation numpy won't find it's DLL's.
Related
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.
I installed numpy and tensorflow using Anaconda. However, anytime I try to import any of them I receive an error which says: dll load failed
I have tried it on VSCode and PyCharm. I also tried installing everything over again. I tried copying the long path given by Anaconda to my system environment variable but nothing seems to be working and I keep getting this:
Traceback (most recent call last):
File "c:/Users/AYERHAN MSUGHTER/Desktop/Anaconda 3/test.py", line 1, in <module>
import numpy as np
File "C:\Users\AYERHAN MSUGHTER\AppData\Local\conda\conda\envs\machinenv\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\AYERHAN MSUGHTER\AppData\Local\conda\conda\envs\machinenv\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinitImportError: DLL load failed: The specified module could not be found.
PS C:\Users\AYERHAN MSUGHTER\Desktop\Anaconda 3>
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/
I am on OS X 10.11.2, Anaconda Python 2.7.10.
I was installing some dependencies, and suddenly, my conda command started not working at all. Many people suggest conda install python=2.7.10 but when I try that (or any command, even just conda) I get:
Traceback (most recent call last): File
"/Users/Can/anaconda/bin/conda", line 5, in
sys.exit(main()) File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/main.py",
line 106, in main
from conda.cli import conda_argparse File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py",
line 16, in
from conda.cli.find_commands import find_commands, find_executable File
"/Users/Can/anaconda/lib/python2.7/site-packages/conda/cli/find_commands.py",
line 9, in
from conda.utils import memoized File "/Users/Can/anaconda/lib/python2.7/site-packages/conda/utils.py", line
10, in
import tempfile File "/Users/Can/anaconda/lib/python2.7/tempfile.py", line 32, in
import io as _io File "/Users/Can/anaconda/lib/python2.7/io.py", line 51, in
import _io ImportError: dlopen(/Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so, 2):
Symbol not found: __PyCodecInfo_GetIncrementalDecoder Referenced
from: /Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so Expected
in: dynamic lookup
How can I repair conda, without using conda itself (as I can't)?
UPDATE: I've completely uninstalled and reinstalled Anaconda. It still gives the same error. I've tried pip and it also fails with the same error. I verify it's Anaconda's pip as which pip returns /Users/Can/anaconda2/bin/pip. Why is Anaconda broken?
I had the same issue, it is successfully fixed by just replacing the _io.so file.
sudo find / -name _io.so
copy the path of the _io.so file which DOES NOT belong to python-2.7.11. For example, copy the path of _io.so which is under python-2.7.5:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Replace the '/Users/Can/anaconda/lib/python2.7/lib-dynload/_io.so' file with the _io.so that you just found.
cp /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so /Users/Can/anaconda/lib/python2.7/lib-dynload/
Then it will work.
Fedora 21, default Python is 2.7, 3.x installed, originally installed iPython, now have also installed Jupyter
When I try to use the Python3 kernel from Jupyter notebook, I get a message saying the kernel has died, attempting restart. Naturally restart never succeeds.
Tried following these 2 terminal commands
ipython kernelspec install-self
ipython3 kernelspec install-self
first command executes without error. second gives this error
ipython3 kernelspec install-self
I used iPython with Python 3 kernel in the past, before installing Jupyter. I don't remember installing ipython3 to do so.
Suggestions how to resolve? I have searched and the above was the only suggestion I found that was not based on using Anaconda.
Also, I do have kernel.json at
~/.ipython/kernels/python3
thank you
UPDATE
last output on terminal when kernel dies
ImportError: No module named 'ptyprocess'
UPDATE2 traceback error
[xxxxx#localhost ~]$ sudo ipython3 kernelspec install-self
Traceback (most recent call last):
File "/bin/ipython3", line 7, in <module>
from IPython import start_ipython
File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 47, in <module>
from .core.application import Application
File "/usr/lib/python3.4/site-packages/IPython/core/application.py", line 24, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python3.4/site-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/usr/lib/python3.4/site-packages/IPython/core/ultratb.py", line 116, in <module>
from IPython.utils import path as util_path
File "/usr/lib/python3.4/site-packages/IPython/utils/path.py", line 19, in <module>
from IPython.utils.process import system
File "/usr/lib/python3.4/site-packages/IPython/utils/process.py", line 19, in <module>
from ._process_posix import system, getoutput, arg_split, check_pid
File "/usr/lib/python3.4/site-packages/IPython/utils/_process_posix.py", line 24, in <module>
import pexpect
File "/usr/lib/python3.4/site-packages/pexpect/__init__.py", line 75, in <module>
from .pty_spawn import spawn, spawnu
File "/usr/lib/python3.4/site-packages/pexpect/pty_spawn.py", line 11, in <module>
import ptyprocess
ImportError: No module named 'ptyprocess'
UPDATE3:
after installing ptyprocess with pip3 new error when trying to create notebook with Python 3...No module named 'path'
[I 22:29:26.125 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 1ae58a7d-096b-4dc1-b29a-bee4385e4e9a restarted
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/site-packages/IPython/__init__.py", line 48, in <module>
from .terminal.embed import embed
File "/usr/lib/python3.4/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.core.interactiveshell import DummyMod
File "/usr/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 31, in <module>
from pickleshare import PickleShareDB
File "/usr/lib/python3.4/site-packages/pickleshare.py", line 41, in <module>
from path import path as Path
ImportError: No module named 'path'
[W 22:29:29.137 NotebookApp] KernelRestarter: restart failed
I've just been installing python, ipython, upyter and pyspark as a kernel. I run into some troubles that seem to be close to what you are having. Many times that I used "sudo ..." I would get the wrong python version. I think somehow sudo run commands without a shell, so if you have any configuration (path, python version,etc), you may not get it applied when using sudo. Something you could do is to run "sudo python", then see if you can import the module path. Also you could try to run "sudo which python" to make sure it's the right version. I found that even if the user had python 2.7 installed, sudo would use python 2.6. For me the best thing to do was to log in as root and do the installation without sudo...
I have just started learning python with the jupyter notebook, and I came across the same problem you did. An associate found the problem - I had crated a python program random.py and saved it into my Python directory. Since random is also the name of a module that I installed, an error message was generated in the Anaconda prompt window. Please check your directories for .py files named after reserved words and modules.