I am very new to python. I have installed on OSX, python3 and jupyter. I launched a notebook, everything is fine. I installed some_package relying on tafile package. When I import some_package, it triggers an error
ModuleNotFoundError: No module named 'tarfile'
The same error is triggered when I import tarfile
I seems that tarfile is related to 2.7 version. Could someone help on how to handle this ?
Related
I am using VSCode with Windows 10 OS, and I have created a Python .venv in 3.7.0 with my interpreter also being 3.7.0. I activated my venv, then pip installed SpeechRecognition and PyAudio successfully.
When I created my main.py as follows, 'os' is recognized but 'speech_recognition' is not.
import os
import speech_recognition as sr
The error message is Import "speech_recognition" could not be resolvedPylancereportMissingImports
My file directory layout:
myproject/.venv
myproject/main.py
Things I have already tried:
Updating Pip
Making Sure Python Venv and Interpreter Versions Match and are compatible with speech_recognition
My best guess is the issue lies within the installation of pip/python, possibly the file path. I have attempted to troubleshoot this with no luck finding the root cause of the errors.
Note: this issue is not particular to this package, my machine frequently has issues recognizing imports
Mark Kapilyn's worked. It was running on pyenv version of python and switched to my global python and it worked.
I am trying to run a script which will trigger a python file. The python file is using win32com.client. From PyCharm everything is running fine. But when I run script it says no module called win32com. I have installed pypiwin32 and pywin32 already. I have tried out below solutions:
Upgraded pip to new version (21.2.3)
Tried with pip install of pypiwin32
Downloaded file from https://github.com/mhammond/pywin32/releases and I have 64bit(AMD64) on win32
Also tried https://github.com/mhammond/pywin32 and installing via python Scripts/pywin32_postinstall.py -install
Added import os;os.environ["PATH"]+=(';'+os.path.join(sitedir,"pywin32_system32")) in pywin32.pth under the folder--\PythonVersion\Lib\site-packages\
Added environmet variables by creating a PYTHONPATH environment variables, and append the win32 and win32/lib path
Tried with import sys
sys.path.append('\\PythonVersion\\lib\\site-packages\\win32')
sys.path.append('\\PythonVersion\\lib\\site-packages\\win32\\lib')
But still the issue is same and somehow I am not able to resolve. Can anyone please help with this?
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 wrote the following python line import scipy.io then I went to that folder's location in the cmd:
C:\Users\me\PycharmProjects\test>
and typed pip install scipy apparently it installed the dependencies then I went back to pycharm, ran my code and got error
ModuleNotFoundError: No module named 'scipy'
I'm just starting off with python I'm on windows 10.
PyCharm has a GUI for managing which python installation you use and packages installed:
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
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