I keep getting this error while trying to import pytorch in jupyter notebook
import torch
AttributeError: function 'AddDllDirectory' not found
this error occur only when I try installing pytorch in anaconda (I used both command to install pytorch pip and conda, I also tried installing only the cpu version and nothing changed, i still get the same error while trying to import it)
I searched the internet and found nothing remotely close to my problem.
is there's a way I can fix this error?
thanks in advance
I fixed the issue by installing the file (KB2533623) from
Here (for windows 7 users). this file apparently contains the missing "AddDllDirectory" function.
Posting this answe in case someone ran into the same problem.
Related
I know that people already did topics on similar question and most of them I've already read, but it still didn't solve my problem, so I hope I could find help here.
I'm new to Python and faced with the same problem of Kernel Error in Jupyter Notebook as it was described here:
Getting kernel error while trying to open Jupyter notebook or Spyder
I use Miniconda and python 3.9 already installed.
I've tried to implement advice that in that topic, but after I installed pywin32, I've faced with the problem of installing pywin32_postinstall. Every time I try to run it, in the output printed "PackagesNotFoundError: The following package are not available from current channels"
(Sorry, but I'm unable to provide complete piece of code, case I don't know how to cope from Anaconda PowerShell Promt)
I would be so much thankful if anyone could help me with this issue!
I'm trying to use anaconda to setup an environment for jupyter notebook. It's not going well... I've got everything working without anaconda (just on the normal windows terminal). On Anaconda terminal however, whenever I try to install jupyter notebook it gives me an import error (could be circular issue it says). I also cannot open anaconda navigator through either the app or command prompt. I have followed documentation and this video. Please any help would be greatly appreciated, I am going to try uninstalling anaconda and then seeing if that gets me any results...
What is the library's name are you trying to import? I am guessing 'jupyter'
Checking your local filenames might be useful. If any files in your project involve the word that is in the import statement, that could prevent the actual jupyter library being imported.
I had the same problem, tried to import numpy and got a similar error. Turns out that I had a file called 'numpy.py' in my project directory. I renamed it and solved the problem.
Try to reset pyzmq by doing the following:
pip uninstall pyzmq
pip install pyzmq
I have been trying to intall scikit-learn and pytorch using their respective commands given in the docs:
The commands for installing PyTorch are:
1) pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-win_amd64.whl
2) pip3 install torchvision
The command for installing scikit-learn is:
pip install -U scikit-learn
Some background:
I am using Windows 8.1, Python 3.7.2. My pip is updated. I have also installed Anaconda for solving this using conda, but had zero luck!(Also, here I am running into 'conda' unrecognized error which is another story). Here are the paths my PATH variable holds.
PATH
C:\Users\satya\Anaconda3;
C:\Users\satya\Anaconda3\Library\mingw-w64\bin;
C:\Users\satya\Anaconda3\Library\usr\bin;
C:\Users\satya\Anaconda3\Library\bin;
C:\Users\satya\Anaconda3\Scripts;
C:\Users\satya\AppData\Local\Programs\Python\Python37\Scripts\;
C:\Users\satya\AppData\Local\Programs\Python\Python37\; C:\Users\satya\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
The Actual Problem:
The same commands for installation given above work perfectly fine on my other Windows 10, but, for my Windows 8.1 it gives this error which has become a real PITA
Import Error: DLL load failed The specified module could not be found
When I import sklearn or import torch I get the exact same error. All the time.
Back Story:
I have searched almost all the related questions I could find on Stackoverflow and Github for 6+ hours to help me solve this problem. But, none of the answers have helped till now and some haven't had an "understandable" answer. Maybe, its just a small fix, but now, I am choosing to post a question on SO.
My Question Again:
Can someone please help out and try to explain what I am missing out here? I really want to fix this error for good(and want to be in a position to fix it if I encounter it again). An elaborate answer would really help understand easily.
Thank You!
Please check your python build number with the following command.
conda list python
Python 3.7.2 with build number h8c8aaf0_2 has a solved issue.
If this is the case, an update will do.
conda update python
I wanted to change my python compiler to "newer" one (within one project) and use some additional packages with conda. After the installation all my packages worked fine and I could use the console, however matplotlib.pyplot fails to import since then. And throws the following error: app = QtGui.QApplication([" "])
AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication'
After doing some research on this I found this one: link
It is suggesting to change inputhooks.py (on line 513 and change GUI_QT:enable_qt4 to GUI_QT: enable_qt5 4 to 5)
As it is a company machine, I can't have admin rights to overwrite things within PyCharm.
Can you recommend a better solution to avoid this?
Why is this popping up?
ErrorLogScreenshot
Also I tried to install the newer version of pyqt but that didn't fix the problem.
In the same time
Within pydev the interactiveshell.py fails as well. with the following error message:self.showtraceback(running_compiled_code=True)
TypeError: showtraceback() got an unexpected keyword argument 'running_compiled_code'
I understand it gets an argument which it is not expecting. I did some research on this one as well and some could fix it by deleting a stale a corresponding .pyc file (I couldn't find one at the same location as the initial file only interactiveshell.py)
Below this blog regarding pydev the conversation never went further
https://github.com/ipython/ipython/issues/10687
Is there a way to fix it?
I am kind of new to Python and don't quite understand the heart of it at this depth so any help is appreciated.
Thanks,
Anna
For anyone having the same issue, I have solved this problem by switching to qt and pyqt 4. To do so, follow the following procedure:
conda remove qt
conda install qt=4
conda install -c anaconda pyqt=4.11.4
conda install matplotlib --no-update-dependencies
If you are not using a virtual environment, you might also have to remove anaconda navigator before installing new packages:
conda uninstall anaconda-navigator
At the beginning of your program, switch matplotlib backend:
import matplotlib.pyplot as plt
plt.switch_backend('Qt4Agg')
Inspired by this solution.
After updating PyCharm all issues seem to have been resolved. (I was using versin 2017.1)
The show traceback error was due to pydev, and the new release fixes it.
As well as the GUI problem.
I was able to solve it by finding the file, and both messages disappeared, and matplotlib seems to work fine again.
Under this folder (I named my environment py35):
C:\Users\myusername\AppData\Local\Continuum\anaconda3\envs\py35\Lib\site-packages\IPython\core__pycache__
I found the file: interactiveshell.cpython-35.pyc and deleted it -
(This solves the problem only on Python 3.5)
Instead of using a Python distribution, I decided to install Scipy myself and stumbled upon Scipy Superpack (http://fonnesbeck.github.io/ScipySuperpack/). After installing Python 2.7.6 I followed the instructions on the website and everything seemed to work without any problems. However, once the installation was done I received a "fatal error" message as I tried to look through my modules. More specifically, the following error:
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
I receive the same error message in the terminal, as well as through IDLE. Despite the error message, I am able to import and use numpy, as well as other modules from the superpack.
I should mention that prior to installing the superpack I installed pip. However, this didn't induce the previously mentioned error.
I am very new to osx, so any advice would be greatly appreciated!
I was also having a lot of problems while trying to install all the python libraries in my mac. I searched on the web for some hours and finally got something that worked out for me.
Scipy is here as well if you want to follow this rules instead:
https://gist.github.com/audy/4012573