I am trying to read a Bigquery query and store into a data frame. I have tried both google.cloud and pandas-gbq packages require pyarrow.
I have installed pyarrow, which I can test through pip show pyarrow:
I can also test through importlib, from which I receive the following answer:
The location shown above is contained on PYTHONPATH from Spyder:
And I can also import pyarrow when running Python from Windows cmd.
But when I try to import it from Spyder I receive the following error:
ModuleNotFoundError: No module named 'pyarrow.lib'
Thanks in advance for those who came this far :)
Solved:
Apparently, Spyder was running default python interpreter version (3.7), while the pyarrow package was only installed for a more updated version, which was already installed (3.9).
I changed the interpreter on which Spyder was running and it worked:
Related
I recently installed anaconda and was using jupyter notebook to write my code. I also installed Visual Studio code and ran my jupyter files (.ipynb) in VSC.
Whenever I try to import pandas in VSC within a jupyter file (.ipynb), I get an error that says ModuleNotFoundError: No module named 'pandas'. However, when I run the same file in Chrome on the Jupyter notebook website, I get no such error and my file is able to import pandas.
How can I fix the problem?
This is due to the fact that when you open an .ipynb file in jupyter-notebook, it is running in a conda environment with pandas installed. And it is running on VSC in a Windows or OS environment, which may not have pandas installed.
On cmd run, pip install pandas then import it on VSC.
I think you are working on a different environment and the error is occurring because pandas module is in different path try installing pandas in your current environment and importing it might work
This might help..
https://code.visualstudio.com/docs/python/environments
Thanks for the above comments. On cmd run (pip show pandas), it actually showed pandas was installed.
However, the reason was because the selected interpreter was a non-conda version, which can be changed in the top right of VCS. Hope this helps anyone who has a similar issue!
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 downloaded the pandas package to my computer using the pip install. When I try to import pandas as pd into Pycharm I get the following error message:
ModuleNotFoundError: No module named 'pandas'
I know I have downloaded the package, but how do I get Pycharm to recognize that I have downloaded the package?
You almost certainly don't have your interpreter set correctly.
Go to preferences -> project -> project interpreter and make sure that the version of Python matches the environment where you did you pip install or conda install.
Also, if you aren't sure which Python you're using you can always run which python.
I installed several conda environments with different Python versions.
After activating my Python 3.5 environment I have installed openpxyl via the line given here: https://anaconda.org/anaconda/openpyxl
However, when I try to import I get
ImportError: No module named 'openpxyl'
When I type conda list I do see
openpyxl 2.4.7 py35_0 anaconda
in the list.
(code to import is just import openpyxl or from openpyxl import *)
Any suggestions? Thanks!
You can try deleting all openpyxl material then reinstall it using pip.
that's how i solved my problem at least.
Even I faced the Same issue. This might Help you. If we have given python path in the windows environment variables which is present before we installed anaconda. We can test it by using
python --version
It will give you the version if the path is already present as
Python 3.6.5
Please remove this path of python which is already mentioned.
Then give the path of the python which is is anaconda directory. Normally it will in the path
C:\Users\lenovo\Anaconda3\
Just add this path to environment variables and again check for the python version
that might give you the following result
Python 3.6.5 :: Anaconda, Inc.
then it is confirmed that you are using the python which is downloaded using anaconda package manager.
Now you use the conda modules anywhere.