ImportError: DLL load failed while importing shell - python

Importing winshell (version 0.6) causes the following error:
>>> import winshell
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python39\lib\site-packages\winshell.py", line 32, in <module>
from win32com.shell import shell, shellcon
ImportError: DLL load failed while importing shell: The specified procedure could not be found.

I finally managed to get Anaconda to start working by executing the line:
pip install pywin32==300
I had to do it twice, because the first time it went for 301, not 300. The second time then dropped it to 300. This was from the Anaconda for Windows installer downloaded just two days ago from the Anaconda website and doing a "clean install"!
What a fiasco!
Until that point, NOTHING really worked. Almost every important command within Anaconda would fail with the Win32com error, and Navigator would not even start. Apparently the latest version of pywin32 is 304, but it doesn't work either. Is anyone looking into this? For a newbie like me, this is a very bad look for Anaconda as a tool! I was on the brink of simply giving up when I literally stumbled onto this thread.
Note that it has been MONTHS between my post and the one before mine. I'd say that this has probably caused a lot of people to simply give up (assuming that there are many who actually try to install this on Windows per month, that is).

I've had similar in the past,was about to give up on Anaconda.
Here's the solution
Apparently the wrong version of pywin32 gets installed.
I had the installed version 301 and after downgrading to 228 with pip install --upgrade pywin32==228 everything just started working.

Try pip install --upgrade pywin32==228
This should resolve the issue

Version 300 of pywin32 solved this issue for me! Check this other question for more info

Had the same issue with Conda and librosa in Python 3.9.
Librosa references from win32com.shell import shellcon,shell, which was causing the same error you received.
Installing pywin32 via conda fixed the error for me:
conda install -c conda-forge librosa

I ran into this issue when trying to get Anaconda to run at all on a new installation. I followed Alex T's recommendation to install version 300 of pywin32. Like him, I had to run it twice because it first installed version 302 for some reason. After running it the second time I can now run conda commands in that environment
pip install pywin32==300

My simple solution is to install an Older version of Anaconda. This worked perfectly for me. I installed Anaconda3-2021.11-Windows-x86 version.
The Newer Version of Anaconda has some problems with pywin32. I first tried the command :
pip install --upgrade pywin32==228
but It didn't workd for me. Installing an older version finally solved the problem of anaconda navigator not launching.

Related

import geopandas successfully, but raise issue with fiona(import error)

I am Windows and using python through jupyternotebook.
python 3.9.7, windows 64 bit,
I want to import geopandas, so I used the code conda install --channel conda-forge geopandas. It seemed work at first because I could successfully import geopandas without error, but when I want to run the following code, an import error appears.
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
world.columns
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: DLL load failed while importing ogrext
I saw other people asked the same questions, but none of their solutions worked. At first, I saw someone said nstalling geopandas by condas might installed wrong version of fiona and gdal. So I tried to update by conda update conda, and conda update -n base conda-package-handling and conda update --all. However, these code didn't work. Later, I directly installed the .whl file from python library: Fiona-1.8.20-cp39-cp39-win_amd64.whl and GDAL-3.4.1-cp39-cp39-win_amd64.whl, and use pip to install them. But the error still appeared.
I really have no idea how to deal with such issue, is it because the version of fiona and gdal was not consistent? Please give me some suggestions, thanks ahead!
I have solved this problem by creating a new environment followed this article: https://medium.com/analytics-vidhya/fastest-way-to-install-geopandas-in-jupyter-notebook-on-windows-8f734e11fa2b
This is the fast way to solve this problem.

No module called 'discord' found

I'm trying to make a discord bot. So I did 'pip install discord' and it installed successfully! I have added Python to PATH as well. now in the Python Shell, I typed, 'import discord'. Then I get this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
I have used 'pip install discord' again and again and it still doesn't work! My pip is also the latest version. I also uninstalled and installed python but still doesn't work! :(
Why does it not work? Please help me. Thanks!!
I think this is because it is
pip install discord.py and not
pip install discord.
If you are on Linux, try pip3 install discord.py (pip installs to python2 by default).
You can also see the official pypi project.
This should be a simple solution. A previous answer indicated to make sure that you use the correct, full module name when making the pip call to install the module, and this is imperative -- however, since you're still not seeing results there is clearly still an issue.
The first question is what is your python download? Did you install python through something like conda, or did you just install the language directly on your device without a facilitating package?
In the meantime (and especially if you don't know the answer to the above question), try this command in your terminal (not your python shell, just your command line):
pip freeze
This command is referenced from this link, in case you're curious, and should give you a list of all locally install non-default python packages. If you provide the result of this call, I am certain it will better facilitate the solving of this issue.
Me to, I got this error.
I solved it as follows:
import discord.abc
if you use linux and run the pip install command as non root but the start command as root you need to run the pip command also as root

Receive an error from lingnutls/'Hogweed' when importing CV2

I've never seen an error like this and don't know where to start. I installed opencv with
conda install opencv
and am running Ubuntu Linux 18.04 using a conda environment named fpn. How should I even approach debugging this?
Traceback (most recent call last):
File "test.py", line 5, in <module>
import cv2
ImportError: /home/s/miniconda3/envs/fpn/lib/python3.7/site-packages/../../././libgnutls.so.30: symbol mpn_add_1 version HOGWEED_4 not defined in file libhogweed.so.4 with link time reference
There seems to be a problem with the recent releases of opencv packages for Conda. I have tested all the 4.x releases and found that the problem occurs starting from 4.3. Unless you really depend on >=4.3, forcing a version prior to 4.3 solves the problem,
name: test
channels:
- anaconda
- conda-forge
dependencies:
- python>=3.8
- opencv<4.3
in my cases this installed 4.2.0. Importing cv2 in Python works fine then. Note that using conda update didn't work for me and I still got the error, but I had to first remove the environment and then re-create it. I think this behavior indicates that the error is rooted in some dependency of opencv, which is not properly down-graded when conda update is used.
I don't consider this a true solution, but installing via pip with
pip install opencv-python
does work with no problem. Shouldn't there be a way to install with conda?
The problem seems to happen with a mix between conda-forge and anaconda packages, which aren't compatible.
I encountered the same problem; the ultimate issue was having conda-forge configured with lower priority than anaconda. This caused the anaconda packages, which were incompatible, to be installed when there was an option.
This is, of course, a bad idea - since conda-forge assumes anaconda availability, but not vice versa

pyodbc module not found

I am facing a situation where modules like pyodbc which used to work earlier (3 weeks back) are not working anymore in my laptop. I am repeatedly getting Module not found error.
To resolve it by myself, I have gone through similar articles in stack overflow and implemented some suggestions like this. Yet the issue still persists. My machine (Windows 10) has only one python version (python v3.7.2), and I have never created any virtualenv.
C:\Users\Kris\eclipse-workspace\SQLPyODBC>conntest.py --serverName "IDEA-PC\SQLEXPRESS" --name "SampleStore" --trustedConn "yes"
Traceback (most recent call last):
File "C:\Users\Kris\eclipse-workspace\SQLPyODBC\conntest.py", line 1, in <module>
import pyodbc
ModuleNotFoundError: No module named 'pyodbc'
The referenced package is available under C:\Users\Kris\AppData\Local\Programs\Python\Python37-32\Lib\site-packages directory. Also the path of python interpreter in eclipse IDE (PyDev) is pointing to correct python executable path.
Just to test, I have downloaded pymssql module, and guess what... it is also showing the same error message. I have uninstalled and re-installed packages. No solution.
If you're using Anaconda install using following code,
conda install -c anaconda pyodbc
Before importing pyodbc in python, you should install the module by using pip directly from cmd.
pip install pyodbc
if that does not work, try using pip to uninstall and install it again after a restart (Or kill all python related tasks). Hope it works

Pyinstaller cannot find Pandas

I use Pandas 0.20.3 and Pyinstaller 3.3.1 on anaconda, Windows7.
I create an executable but when I run it I get "no module named pandas" error. For testing, I also made a basic file as follows which yielded the same error when I created the exe file :
import pandas
print("x")
I followed the steps described in the 2 answers in this thread but nothing has changed. My only doubt is regarding the sentence below which is a part of the the second answer in the thread:
"I reinstalled pyinstaller manually via python setup.py install in the
Pyinstaller directory."
I am not sure if I got this but I just uninstalled and reinstalled pyinstaller via pip to replicate this.
So it turns out the problem was related to having Anaconda installed. Once I uninstalled pandas from anaconda the answer of physicistintheory in this discussion worked.
Anaconda is a great tool but for this time I had to avoid it.

Categories