I'm trying to compile a Python project (using Python 2.7 on Windows XP) into an EXE using PyInstaller with the default options. When I try to run the EXE, I get the message:
PyInstaller - ImportError: No module named win32api
I added the win32api path to the windows PATH environment variable (I do have Python Win32 Extensions installed) but it's not working. I'm pretty new to this and a little overwhelmed by all the options etc, and I really have no idea where to start (or what information would be useful to solving this problem.) I assume this is some little thing that I'm missing, but I haven't found anyone having precisely this problem online and any help would be greatly appreciated.
Ok, it looks like "import os" in one of my modules was causing this issue. I had no luck getting it to successfully use the win32api module, but since this was only being used to set the program name, I just commented this out and this particular issue is resolved. Thanks Luke for your help!
Related
this might be a very stupid question but I'm a beginner.
I want to use this package called colorgram, it's a module that extracts colours from images, and I installed it using pip via the CMD. but when I try to import it in VS code it can't find it and I don't know what to do, please help
#Andrii Zadaianchuk
sorry, I'm using windows 10. I tried to import it in python in the CMD but nothing either, just the same ModuleNotFoundError: No module named 'colorgram' error.
I did just notice that the modules python version is 3.5 and VS code is running 3.9.2. I think that might be the problem
A C++ python module based on pybind11 library cannot be imported anymore in python. It was working until a few weeks ago but not any more (may be since the installation of miniconda). Cannot track the exact point when this stopped working as I was not using it since many weeks. I start python in the same directory as the module, and tried to import it in the terminal. And I get the error:
ModuleNotFoundError: No module named 'ld_pybind_d'
In the mean while I also tried:
deleted the directory where miniconda was installed, rebuilt the module and linked it against python3.6m library.
Created an empty __ init__.py file in the module directory
Exported the current working directory in the PYTHONPATH environment variable
Other info:
Built 64 bit version module and I also have 64 bit version python
Python version 3.6.8
Nothing works .. Your help is very appreciated ...
As is, many times the case, if nothing really works, a restart would definitely do. I did that and seems to solve the case. Never the less, im just relieved it is loading now.
Im my Python file, I have imported the win32gui module like this:
import win32gui
I have also downloaded win32gui but don't know how to make my script run. How can I run my Python script which imports win32gui? When I run it, I get:
ImportError: No module named win32gui
Sorry for the newbie question but I'm trying to learn Python so don't know much about it.
When on a windows platform, I usually go for the executables. They should work all the time. Try perhaps one of the files listed here:
http://sourceforge.net/projects/pywin32/files/pywin32/Build216/
It's the most recent build. Choose the one appropriate to your Python's version.
this is a module from Marc Hammond's well-known pywin32 extension module, you can also get the source and compile it quite easily (I found I needed to do this because I needed a 64 bit build and couldn't find one at the time). The mercurial address to get it is:
http://pywin32.hg.sourceforge.net:8000/hgroot/pywin32/pywin32
there are visual studio project files in the .\pywin32\win32 directory...
Hey all, I'm pretty new to python, so bear with me.
I want to write a simple script using some components of PyObjC. I'm running on Mac OS 10.5, so from what I've read, it's included.
However, opening up a simple python prompt and typing import Foundation gives me the error ImportError: No module named Foundation.
For reference, my sys.path is
['', '/var/hg/lib/python2.4/site-packages', '/Users/dmitri/lib/python',
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PyObjC',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyObjC',
'/Users/dmitri', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages']
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PyObjC', and '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyObjC', got in there because I was fooling around, but they don't seem to help me. The 2.4 version seems to exists but there, seems to be no folder with the aforementioned path in the 2.5 version.
I found it - for some reason, it was located under /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python, so I had to just add that whole directory to my $PYTHONPATH
Where is the module Foundation located? Assuming it's in the same place as PyObjC -- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ -- then you have to add /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ to your $PYTHONPATH as well.
When I write import MySQLdb in Eclipse using the PyDev plugin, I get an unresolved import. However, the program runs without error. I can add an annotation to get the error to go away, but what is the right way to handle this?
How can I help Eclipse know that MySQLdb is there?
It sounds like MySQLdb is somewhere on your sys.path, but not on your Eclipse project's PYTHONPATH; in other words, Eclipse thinks you're going to get an import error at runtime because you haven't fully configured it. Google seems to say that you can alter this setting in Window->Preferences->Preferences->PyDev->Python Interpreter to include the path to your MySQLdb module.
For some help figuring out where MySQLdb might be living on your system:
Open an interactive interpreter,
import MySQLdb
If that succeeds, you can get a hint from: print MySQLdb.__file__; it may be the __init__ file in the package that you need to point the path at.
cdleary above provided the reason two years ago, but this may be easier. Basically, one reinstalls the interpreter.
Select Window - > Preferences -> PyDev -> Interpreter - Python
Select the python interpreter in the upper pane
Click on Remove
Click on Auto Config
Agree to everything.
This works on Fedora 17 using the Eclipse 4.2.0 that came with the package management.
Fixed this by doing two things:
1) Added MySQLdb egg to the PYTHONPATH under Window->Preferences->Preferences->PyDev->Python Interpreter.
C:\Python26\Lib\site-packages\MySQL_python-1.2.3c1-py2.6-win32.egg
2) Close and re-open the .py file that had the red x.
Adding the egg works, but the error remains. The solution for that error can be found by adding
##UnresolvedImport
To the import statement, as in:
import web ##UnresolvedImport
Source: http://klaith.wordpress.com/2009/06/12/pydev-unresolved-import-errors/
I once had a similar problem on Windows (never encountered this on Linux though) and I discovered that I had to include the .egg directory of my library to my PYTHONPATH.
For example my PYTHONPATH (Pydev/Interpreter - Python/Libraries) included:
C:\Python26\Lib\site-packages
and I had to add:
C:\Python26\Lib\site-packages\jinja2-2.2.1-py2.6.egg
to use jinja.
This surely works I just tried it with Pmw package. Unzip package in site-packages. Then remove python interpreter from eclipse and then add it again. Your import errors shall go away. also you may want add module to forced builtins. See How do I fix PyDev "Undefined variable from import" errors? and http://pydev.org/manual_101_interpreter.html
I had a similar issue and the following is what I did to solve my issue. I have a Windows 8 Machine, Python 2.7 installed and running my stuff through eclipse.
Some Background:
When I did an easy install it tries to install MySQL-python 1.2.5 which failed with an error: Unable to find vcvarsall.bat. I did an easy_install of pip and tried the pip install which also failed with a similar error. They both reference vcvarsall.bat which is something to do with visual studio, since I don't have visual studio on my machine, it left me looking for a different solution, which I share below.
The Solution:
Reinstall python 2.7.8 from 2.7.8 from https://www.python.org/download this will add any missing registry settings, which is required by the next install.
Install 1.2.4 from http://pypi.python.org/pypi/MySQL-python/1.2.4
After I did both of those installs, I reopened eclipse and got a prompt to update the paths of eclipse which I accepted, after that I was able to query my MySQL db.
import MySQLdb
If this code show error like this:
Unresolved import: MySQLdb
you should add D:\Python27\Lib\site-packages\MySQLdb to your sys.path.
D:\Python27\Lib\site-packages\MySQLdb is this location where you install MySQLdb in your computer disk. After this step, the error will disappear.