Error when using winshell module: No module named 'win32' - python

import winshell
r = list(winshell.recycle_bin())
for index, value in enumerate(r):
print(index, value.original_filename())
This is the simple script I wrote, but when I try running it (or antyhing else that uses winshell) I get this error:
ModuleNotFoundError: No module named 'win32'
And when I try running pip install win32 I get another error:
ERROR: Could not find a version that satisfies the requirement win32 (from versions: none)
ERROR: No matching distribution found for win32
So now I'm even more confused. Why does winshell need a different module? That module doesn't even exist. Is it fine if I use some different module than the non-existent win32? If so which one? What am I supposed to do now?

First, you have to execute the script inside the Scripts directory, the pywin32_postinstall.py. Let’s say your Python directory is C:\python3, just follow the code below.
cd C:\python3
python Scripts/pywin32_postinstall.py -install
After that, the installation will drop the DLL files under the C:\Windows\System32. You need to move those two files ( pythoncom310.dll and pywintypes310.dll) to C:\python3\Lib\site-packages\win32 directory.
After that, you need to edit the python310._pth that you can find inside the Python installation folder. Then make the following changes:
Lib/site-packages
Lib/site-packages/win32
Lib/site-packages/win32/lib
Lib/site-packages/pythonwin
python310.zip
#Uncomment to run site.main() automatically
#import site
Save and try running your code again.
Troubleshoot
If you still get an error saying “ImportError: DLL load failed while importing win32api: The specified module could not be found.”, make sure you have copied the two dll files to Lib\site-packages\win32 directory.
PythonWin32Api

Related

Cant import local module

So I am trying to use this repository on my computer but I cant seem to import a local module (Agent.pyx) and use functions from that file. The error I get is:
ModuleNotFoundError: No module named 'RLAgent.Agent
Screenshot of error
Link to repository
You have to install the package manually
Since Agent.pyx is a .pyx file, you will need to first build it. The README file in the linked repo also mentions this. So you need to move to the RLAgent directory and execute the setup instruction as:
cd RLAgent
python3 setup.py build_ext --inplace
This will build the required .c and .so file which will then enable it's import in other files such as Train.py which is where the import is throwing an error.

xdis.code ModuleNotFoundError but the module have already installed

I am trying to convert .pyasm file to .pyc or .pyfile by xdis, xasm and uncompyled6. I have read through this page.
However when i type the command sudo python /Users/frank/anaconda/envs/py380/lib/python3.8/site-packages/xasm/xasm_cli.py /Users/frank/Desktop/111/flag.pyasm It returns the error:
ModuleNotFoundError: No module named 'xdis.code'
However, i have already installed xdis,xasm and uncompyle6 with newest version.
I cannot figure out why. Any suggestions? My environment is MacOS with python3.8.0

ImportError: No module named 'xx' in mac and linux

I am right now using the mac and trying to use the module pypng. I have installed the module from pip install pypng. It works well. However when I run my application python test.py (where inside test.py has 'import png'), it gives me a error saying 'ImportError:No module named png'.
However when I go into the python environment from command line, I type 'import png', it works without a error, why is that. I even restart the computer, but still in trouble.
when I installed pypng module, it tells me it is install in /Users/abc1/anaconda/lib/python2.7/site-packages, where inside this directory I can find the png.py and png.pyc.
when i print sys.path, this is the output, looks like it didn't load the png package from /Users/abc1/anaconda/lib/python2.7/site-packages. how do i solve it
['/Applications/Blender/blender.app/Contents/Resources/2.76/scripts/addons_contrib', '/Applications/Blender/blender.app/Contents/Resources/2.76/scripts/addons', '/Applications/Blender/blender.app/Contents/Resources/2.76/scripts/modules', '/Applications/Blender/blender.app/Contents/Resources/2.76/scripts/startup', '/Applications/Blender/blender.app/Contents/MacOS/../Resources/2.76/scripts/modules', '/Applications/Blender/blender.app/Contents/Resources/2.76/python/lib/python34.zip', '/Applications/Blender/blender.app/Contents/Resources/2.76/python/lib/python3.4', '/Applications/Blender/blender.app/Contents/Resources/2.76/python/lib/python3.4/plat-darwin', '/Applications/Blender/blender.app/Contents/Resources/2.76/python/lib/python3.4/lib-dynload', '/Applications/Blender/blender.app/Contents/Resources/2.76/python/lib/python3.4/site-packages', '/Applications/Blender/blender.app/Contents/MacOS/../Resources/2.76/scripts/freestyle/modules', '/Applications/Blender/blender.app/Contents/Resources/2.76/scripts/addons/modules', '/Users/xisizhe/Library/Application Support/Blender/2.76/scripts/addons/modules']
Maybe you installed png to your python environment in the command line but not the environment you run your script. Try to use python batch.py in command line, or append /Users/abc1/anaconda/lib/python2.7/site-packages to sys.path.
Do you have a directory in your project that is named png? If so python will try to import it instead of the actual module

Errors building Boost.Python tutorial example on Windows

I'm trying to set up Boost.Python 1.54.0 on Windows 7, python 2.7.3. I installed boost_1_54_0 and built it with Visual Studio 2010. I can build and run the quickstart and tutorial examples in the distribution (I had to add some MSVC lib dirs as library-path requirements in Jamroot, but that's OK). But when I copy the tutorial example to a different dir, not inside the boost dist dir, to make it more like a real project, bjam gives build errors. I changed the use-project boost location in Jamroot to /local/boost_1_54_0/ which is where boost wanted to install itself, and added a simple one-line boost-build.jam (based on something I found online):
boost-build C:/local/boost_1_54_0/tools/build/v2 ;
but ultimately bjam gives me this error:
% bjam
notice: no Python configured in user-config.jam
notice: will use default configuration
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:262: in find-jamfile from module project
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory '/local/boost_1_54_0'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:280: in load-jamfile from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:64: in load from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:89: in load-used-projects from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:75: in load from module project
C:/local/boost_1_54_0/tools/build/v2/build\project.jam:145: in project.find from module project
C:/local/boost_1_54_0/tools/build/v2\build-system.jam:535: in load from module build-system
C:\local\boost_1_54_0\tools\build\v2/kernel\modules.jam:289: in import from module modules
C:\local\boost_1_54_0\tools\build\v2/kernel/bootstrap.jam:139: in boost-build from module
C:\tmp\tutorial\boost-build.jam:1: in module scope from module
What else do I need to add, or what am I doing wrong?
I ended up giving up on bjam for this, and just used SCons. A simple SConstruct was enough:
# SConstruct for building boost python tutorial example
import os
boost_python_lib = 'boost_python-vc100-gd-1_54'
boost_top = 'c:/boost'
python_top = 'c:/python27'
env=Environment(TARGET_ARCH='x86',
CCFLAGS=['/MDd', '/DEBUG', '/EHsc'],
CPPPATH=[os.path.join(boost_top,'include/boost-1_54'),
os.path.join(python_top, 'include')],
LIBPATH=[os.path.join(boost_top, 'lib/i386'),
os.path.join(python_top, 'libs')])
dll=env.SharedLibrary('hello_ext', 'hello.cpp',
LIBS=boost_python_lib)
env.InstallAs('hello_ext.pyd', dll[0])
# Copy the boost python lib into this dir so hello_ext will find it at runtime
env.Install('.', os.path.join(boost_top, 'lib/i386', '%s.dll'%boost_python_lib))
Of course you could make a real SCons Tool out of this, but that was enough to get me going. Hope it's useful to others.

ImportError: No module named pyqt_ui.qt_translator

I'm attempting to package a python application (Mnemosyne) using py2app (I didn't write the software; I am only attempting to package it).
I have built the application with py2app:
sudo python setup.py py2app
and copied the qt_menu.nib directory into the Resources directory.
When I then attempt to launch the application:
./dist/Mnemosyne.app/Contents/MacOS/Mnemosyne
I get this error:
ImportError: No module named pyqt_ui.qt_translator
I haven't been able to figure out what to add to the "includes" to ensure qt_translator is included.
I read the list of PyQT modules but I couldn't find which module I need to include to get qt_translator. I learned that there is a QTranslator class in the QtCore module, but including PyQt4.QtCore doesn't help, nor does PyQt4*.
The line in the code that seems to be causing this is:
mnemosyne.components.insert(0,
("mnemosyne.pyqt_ui.qt_translator",
"QtTranslator"))
The class you are missing is part of the package that you download when you download the Mnemosyne tarball it is in the folder mnemosyne/pyqt_ui file name qt_translator.py you need to extract the entire tarball and cd into it in terminal then use py2app.

Categories

Resources