ImportError: No module named win32api Error - python

When trying to import win32api, win32con modules for my code, I have been getting the following error:
Traceback (most recent call last):
File "C:\Users\Henil\Desktop\LinkedIn-Easy-Apply-Automation-master\LinkedInEasyApply.py", line 16, in <module>
import win32api, win32con
ImportError: No module named win32api
So I ran pip install pypiwin32 and the installation went through. But when running the code I get the same "No Module Found".
So I tried pip install -U pypiwin32 and I get the following output:
pip install -U pypiwin32
Requirement already up-to-date: pypiwin32 in c:\python27\lib\site-packages
Requirement already up-to-date: pywin32>=223 in c:\python27\lib\site-packages (from pypiwin32)
However, when I run the program I still get "No module found" error. Do I need to change paths somehow?
I am on Windows 10 64 bit machine.

In my case, i'm importing this modules:
import win32com.client as win32
from win32com.client import Dispatch
win32c = win32.constants
I'm using win32 to open Excel files:
excel = win32.gencache.EnsureDispatch('Excel.Application')
wb = excel.Workbooks.Open(xlsx_file)
wb.Save()
excel.Application.Quit()

Related

how can I install win32con?

I'm trying to use winshell to generate a url shortcut file,
so I did:
pip installed winshell
However on line 30 of the winshell.py file it requires the module win32con : my understanding is that win32con is apart of pywin32, which is already installed.
The specific error I get when trying to import win32con is:
(base) C:\Users\deana>pip install win32con
ERROR: Could not find a version that satisfies the requirement win32con (from versions: none)
ERROR: No matching distribution found for win32con
I've found a few references online and on stack exchange but nothing.
running windows 11.
pip install pywin32
Happy to help.

Tensorflow - ModuleNotFoundError: No module named 'reverb'

When i run a python program, it shows the error message
sam#MSI:~/circuit-training$ python3 -m circuit_training.learning.ppo_reverb_server --root_dir=${ROOT_DIR} --port=${REVERB_PORT}
Traceback (most recent call last):
from circuit_training.learning import ppo_reverb_server_lib
File "/home/sam/circuit-training/circuit_training/learning/ppo_reverb_server_lib.py", line 20, in
import reverb
ModuleNotFoundError: No module named 'reverb'
To solve it, I install the packages by using pip install reverb, and it shows
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: reverb in /home/sam/.local/lib/python3.8/site-packages (2.0.1)
It seems like i already have this package, but when i import reverb, it still saying that ModuleNotFoundError: No module named 'reverb'
Is it because import cannot find the package path?

ModuleNotFoundError when I `import pillow`

I'm trying to use pillow however pip claims to have downloaded it already yet it will not run. Here is my console:
➜ Downloads pip3 install Pillow
Requirement already satisfied: Pillow in /usr/local/lib/python3.6/site- packages
Requirement already satisfied: olefile in /usr/local/lib/python3.6/site- packages (from Pillow)
➜ Downloads cat code.py
import pillow
➜ Downloads python3 code.py
Traceback (most recent call last):
File "code.py", line 1, in <module>
import pillow
ModuleNotFoundError: No module named 'pillow'
➜ Downloads
Thanks as always for the help
You should still import PIL but not pillow.
The problem as far as I can see is that
import pillow
is not used by Pillow to import the library.
Based on their documentation - http://pillow.readthedocs.io/en/4.3.x/handbook/tutorial.html - you should use:
import PIL

No module named openpyxl - Python 3.6 - OSX

I've installed openpyxl from the Terminal using
pip3 install openpyxl
without any problems. I've even double-checked by simply running import openpyxl from the Terminal window once Python is running, and it imports no problem.
The problem starts when I try and import openpyxl from a script I'm building to work with a spreadsheet. I'm using Sublime Text and can't even get past the import openpyxl at the beginning of the script without running into the following error:
Traceback (most recent call last):
File "/Users/wcw/Desktop/test.py", line 1, in
import openpyxl
ImportError: No module named openpyxl
How can this be happening? I know I've installed openpyxl correctly from the Terminal window without any errors so how can my script not find the module?
Try to do:
pip3 install --user openpyxl
Doing the --user worked for me when I tried to run my .py files with matplot lib modules which worked in 3.5 but not in 3.6.
I have the same problem.
I've installed the openpyxl succesfully via Anaconda
!pip3 install --upgrade openpyxl
Collecting openpyxl Using cached
https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz
Requirement already satisfied, skipping upgrade: jdcal in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.4.1) Requirement already satisfied, skipping upgrade:
et_xmlfile in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.0.1) Installing collected packages: openpyxl Found
existing installation: openpyxl 1.8.6
Uninstalling openpyxl-1.8.6:
Successfully uninstalled openpyxl-1.8.6 Running setup.py install for openpyxl ... done Successfully installed openpyxl-3.0.3
But when I try to use tat library I get an error No module named openpyxl
import openpyxl
ModuleNotFoundError: No module named 'openpyxl'
If I try to import openpyxl in Terminal, I don't have the error. What's wrong?
This may be overly simplistic, but I had the same problem. I installed the module successfully but import openpyxl resulted in an error. I needed to close IDLE and start a new session. After that, my import command worked just fine.

Import error in pyPDF2 when it is correctly installed

I am using python 2.7.6 on Ubuntu 14.04 LTS. When I run this command:
sudo pip install pypdf2
The following message shows up:
Requirement already satisfied (use --upgrade to upgrade):
pypdf2 in /usr/local/lib/python2.7/dist-packages
Cleaning up...
This means that pypdf2 is already installed on my system but when I try to import pyPDF2, this message comes up:
>>> import pyPDF2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyPDF2
Capitalization counts. Try import PyPDF2 and see if that works.

Categories