Trying to get the samplebinding example working, but no matter the compiler, python or pyside version used, I still get
ImportError: DLL load failed while importing Universe: The specified module could not be found.
Last configuration used:
VS2019
cmake 3.16.2
python 3.81 amd64 from python.org
pyside2, shiboken2 5.14.1 from pip
shiboken-generator whl 5.14.1 from here
Library is compiling fine:
Python 3.8 changed the dll path resolution.
Adding the shiboken2.abi3.dll to the folder resolved the issue.
Modify the import to be Python3 compatible:
from build.Universe import Icecream, Truck
The import of __future__.print_function suggests the file is still written for Python2.
Related
When I import a package I built that depends on numpy (via pandas), the numpy import fails with the message below. VS Code is not in the picture.
I'm running macOS Monterey (12.3.1) on a MacBook Pro with an M1 chip.
I installed Python 3.10 from binary.
I'm using virtualenv and VS Code for development, but the failure also occurs when I run a script from Terminal.
I built a package (PyTables) that uses pandas and numpy: PyTables. It runs just fine in that project on my machine.
However, when install that built package in another project -- pip install -i https://test.pypi.org/simple/ pytables -- and then import it -- import pytables as tp -- I get the numpy import error below.
I've isolated the problem to just that import statement.
I installed pandas 1.4.1 and numpy 1.22.1 in this virtualenv using pip3, just as I did in the env where I built the package.
I also have Python 3.9.1 on my system. I need 3.10 for PySimpleGUI.
If I simply comment out the import, the code runs fine.
Import error:
ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
The Python version is: Python3.10 from
"/Users/alecramsay/.virtualenvs/tstudio/bin/python" * The NumPy
version is: "1.22.1"
and make sure that they are the versions you expect. Please carefully
study the documentation linked above for further help.
Original error was:
dlopen(/Users/alecramsay/.virtualenvs/tstudio/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried:
'/Users/alecramsay/.virtualenvs/tstudio/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need
'x86_64'))
I'm using python 3.6 and attempting to import win32com.client as win32 to be able to send an email with outlook but keep getting the above import error.
I've installed both pywin32 and pypiwin32 and run the postinstall script (did see it say "You do not have the permissions to install COM objects.)
I see the pywintpyes36.dll and pyhoncom36.dll in the location I'm running the script out of.
I've done a bit of searching and can't seem to find what I'm missing. Is it the fact that I was unable to install the COM objects? Any help would be greatly appreciated, thanks.
[EDIT]
I'm working out of a venv, and have installed both libraries using py -m pip install pywin32 and py -m install pypiwin32. I verified that I see the installation in the "site-packages" folder within my venv.
my imports:
import sys
sys.path.append("C:\path\venv\Lib\site-packages")
import tkinter as tk
import getpass
import os.path
import time
import os
import win32com.client as win32
import sqlite3
from datetime import datetime
from functools import partial
I have the sys.path.append there otherwise the module is not found at all.
Full error message:
Traceback (most recent call last):
File "C:\path\program.py", line 8, in <module>
import win32com.client as win32
File "C:\path\venv\Lib\site-packages\win32com\__init__.py", line 5, in <module>
from win32 import win32api
ImportError: DLL load failed: The specified module could not be found.
This may not be directly relevant for the OP, but may be of help to others who end up here based on the title.
Summary
Possible workaround for conda environments with Python>=3.8:
DO NOT pip install pywin32, but
DO conda install pywin32 (e.g. from conda-forge)
Details
I encountered the following error in a freshly created (Mini-)Conda environment with Python 3.9 on windows 10, after installing pywin32 via pip:
ImportError: DLL load failed while importing win32file: The specified module could not be found.
The pywin32 installation instructions mention this type of issue explicitly, and there are several related issues.
However, in my case something else was going on.
Here are some interesting observations:
I have numerous other, pre-existing, conda environments, with python versions ranging from 2.7 to 3.8, and corresponding pywin32 versions, in which the issue does not arise (just verified this).
All these environments have their own pywintypesXX.dll etc. yet they coexist peacefully.
There is no pywintypesXX.dll in my system32 folder.
I have never needed to run the pywin32_postinstall script, yet.
As it turns out, on my system, the import error only arises if I do a pip install pywin32 in a conda environment with Python>=3.8. The issue does not arise for Python 3.7 (nor for 2.7).
In a Python>=3.8 conda environment, conda install pywin32 fixed the issue (instead of using pip).
Apparently Python 3.8 changed the way dll files are found. This change has been incorporated in pywin32, but can still cause trouble if you mix conda and pip.
Related:
DLL load failed: The specified procedure could not be found. win32api, sys, os
How to fix "ImportError: DLL load failed" while importing win32api
How to fix 'DLL load failed while importing win32api' in Jupyter notebook after connecting VS code to Jupyter notebook?
I have successfully managed to build and install PySide2 on Python 3.6.4. (default, not Anaconda) on Windows 10 operating system.
However shiboken2 has not been installed. How may I install shiboken2? I know that that the code for this module is attached to PySide2 installation files.
I suspect that my C++ code which is built as DLL file cannot be imported in Python due to missing shiboken2. However this importing works fine in Anaconda environment. But at the moment I do not want to use Anaconda because there are old versions of 'Qt' (5.6 but I need 5.9.x) and 'PySide2' installed.
Just a moment ago I figured it out that shiboken2 can be imported like this:
from PySide2 import shiboken2
So before importing my own files the above line has to be added.
I'm using python 2.6.6 (32bits) on windows 7 and I try to upgrade from Pandas 0.13.0 to Pandas 0.14.1
I can't upgrade to newer version of python due to IT policy.
I tried using the tar.gz package, using the compiled pandas version found here pandas‑0.14.1.win32‑py2.6.exe, even reinstalling everything (numpy, py-tz, dateutil...), but I got always the same error:
File "c:\python26\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: DLL load failed: The specified procedure could not be found.
I defined the python path PYTHONPATH to C:\Python26\Lib;C:\Python26\DLLs;C:\Python26\Lib\lib-tk; but it does not make any difference. However the hashtable.pyd, tslib.pyd and lib.pyd do exist in the proper directory.
I've googled the problem, and in some case using the exe from the site of Christoph Gohlke helps , but I already tried and the error is always the same.
Any idea? So far I'm blocked to version 0.13.0 as even 0.13.1 gives the same error.
Thanks.
In Python 3.4 from Anaconda, I created a program and it is giving me and import error each time I run it.
Using Spyder.
ImportError: No module named 'win32api'
I already have the pywin32 installed. And I can see the win32api.pyd under C:\Anaconda3\Lib\site-packages\win32
This is the import code on my program:
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
import time
import requests #needs to be installed
import pymysql #needs to be installed
import csv
import win32com.client #needs to be installed
import datetime
This is the whole error:
File "C:\Anaconda3\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: No module named 'win32api'
This is the only instance of Python I have installed. I uninstalled everything else and installed only Anaconda.
Searching online I got to something that said that it could be a problem with the PYTHONPATH. But honestly, I have no idea what they are talking about.
So any noob help would be really appreciated.
I am using Windows 7 by the way.
Thank you
The installation for pywin32 must have failed, or it is not for same OS bit architecture (say anaconda 64 bit and pywin32 32 bit). I recommend
you uninstall pywin32,
check what bit version of anaconda you are using, then
install pywin32 for same version,
verify that the installer indicates 100% success and there are no errors flagged in the installer's log window (it's rare but something may fail and the installer doesn't know).
Then open a python console and type "import win32com".
If #5 fails to import win32com, then:
try installing a different version of python, for example from python.org
repeat steps 2 to 5 above but for new python instead of anaconda
Could be that anaconda distributors did something to the python interpreter (although I didn't think so), or that some libs aren't registered right (see answer https://stackoverflow.com/a/17061853/869951 for some more things to try).
This should work:
pip install pypiwin32
I had the same problem and solved it installing the module pywin32:
In a normal python:
pip install pywin32
In anaconda:
conda install pywin32
My python installation (Intel® Distribution for Python) had some kind of dependency problem and was giving this error. After installing this module I never more saw it.
As mentioned by outforawhile in comment, simply restarting the laptop fixed this for me.
It may be that this is required for Windows to register the DLL.
try this before install pywin32
pip install pywinutils