Issue after downgrading pandas - python

I recently tried to downgrade pandas to version 1.2.3 using pip, but clearly messed something up. Sadly I was not in my environment so it is messed up everywhere. How do I get correct for this?
I have homebrew too.
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:33)
[Clang 13.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "__init__.pxd", line 942, in numpy.import_array
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jremmert/miniforge3/lib/python3.9/site-packages/pandas/__init__.py", line 29, in <module>
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
File "/Users/jremmert/miniforge3/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
File "/Users/jremmert/miniforge3/lib/python3.9/site-packages/pandas/_libs/tslibs/__init__.py", line 30, in <module>
from .conversion import OutOfBoundsTimedelta, localize_pydatetime
File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
File "pandas/_libs/tslibs/nattype.pyx", line 30, in init pandas._libs.tslibs.nattype
File "__init__.pxd", line 944, in numpy.import_array
ImportError: numpy.core.multiarray failed to import
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jremmert/miniforge3/lib/python3.9/site-packages/pandas/__init__.py", line 33, in <module>
raise ImportError(
ImportError: C extension: numpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.

Related

Is there any way to fix azure cli import pyparsing error on mac?

I'm trying to run azure CLI after reinstalling it I'm getting:
$ az
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/Cellar/python#3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/azure/__init__.py", line 1, in <module>
__import__('pkg_resources').declare_namespace(__name__)
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/__init__.py", line 78, in <module>
__import__('pkg_resources.extern.packaging.requirements')
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/extern/__init__.py", line 52, in create_module
return self.load_module(spec.name)
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pkg_resources/extern/__init__.py", line 44, in load_module
raise ImportError(
ImportError: The 'pyparsing' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
I checked the python binary path and I saw I already have this package.
Found the issue.
One of the sub-packages that called in the pyparsing package was called to a local folder script that has the same name. and as a result the import faild.
$ /usr/local/Cellar/azure-cli/2.25.0/libexec/bin/python
Python 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyparsing
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/azure-cli/2.25.0/libexec/lib/python3.8/site-packages/pyparsing.py", line 104, in <module>
import copy
File "/Users/shprayev/copy.py", line 4, in <module>
from pymongo import MongoClient
ModuleNotFoundError: No module named 'pymongo'
So pyparsing imports copy and I had copy.py in my path.
after rename the script it worked

Pandas Import Fails with Conda on Python 3.7.9

I have installed conda and created a python3.7 environment. Then I have installed pandas and now I'm getting the following error when I try to import pandas.
Traceback (most recent call last):
File "/me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/__init__.py", line 29, in <module>
File "/me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/_libs/__init__.py", line 13, in <module>
ImportError: /me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/_libs/interval.cpython-37m-x86_64-linux-gnu.so: invalid ELF header
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/__init__.py", line 37, in <module>
ImportError: C extension: /me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/_libs/interval.cpython-37m-x86_64-linux-gnu.so: invalid ELF header not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.Traceback (most recent call last):
File "/me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/__init__.py", line 29, in <module>
File "/me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/_libs/__init__.py", line 13, in <module>
ImportError: /me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/_libs/interval.cpython-37m-x86_64-linux-gnu.so: invalid ELF header
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/__init__.py", line 37, in <module>
ImportError: C extension: /me/anaconda3/envs/py37/lib/python3.7/site-packages/pandas/_libs/interval.cpython-37m-x86_64-linux-gnu.so: invalid ELF header not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.
Any ideas?
It turns out this is a bug with conda and pandas.
Here is the ticket:
BUG: Pandas Import is failing under Conda Python 3.7
Using conda-forge fixed the issue for me.

Python imports not working after interrupt

I was running a Tensorflow code then interrupted it via ctrl+c. I then re-ran it immediately after (without making any adjustments to the code) and am now unable to import anything, even Tensorflow. I looked through some internet searches for a similar problem but have yet to find any that is related.
Re-running the script:
(env_maskrcnn) haziq#vita-workstation2:~/human-pose-3d$ ./run2.sh
Traceback (most recent call last):
File "src/predict_3dpose.py", line 13, in <module>
import h5py
ModuleNotFoundError: No module named 'h5py'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "src/predict_3dpose.py", line 13, in <module>
import h5py
ModuleNotFoundError: No module named 'h5py'
Launching Python 3 to import Tensorflow:
(env_maskrcnn) haziq#vita-workstation2:~/human-pose-3d$ python3
Python 3.7.1 (default, Oct 22 2018, 11:21:55)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Following the instructions given by Manish Dash, I checked the path that Python is pointing to. I am using Python 3 and it looks like it isn't not pointing to the correct path. I also checked the folder /home/haziq/env_maskrcnn/bin/ but did not see a python3 file. What could have happened and how do I fix it?
haziq#vita-workstation2:~$ source env_maskrcnn/bin/activate
(env_maskrcnn) haziq#vita-workstation2:~$ which python
/home/haziq/env_maskrcnn/bin/python
(env_maskrcnn) haziq#vita-workstation2:~$ which python3
/usr/bin/python3

Error when importing tensorflow; says several modules are missing

I installed tensorflow in Windows 7 (32 bit) with Anaconda according to the instructions given here. But when trying to import tensorflow, I get the following error:
(tensorflow) C:\Users\h473>python
Python 3.5.5 |Anaconda, Inc.| (default, Apr 7 2018, 04:53:16) [MSC v.1900 32 bi
t (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_imp
ort_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [
dirname(__file__)])
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\imp.
py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_imp
ort_helper
import _pywrap_tensorflow_internal
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_imp
ort_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [
dirname(__file__)])
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\imp.
py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\h473\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site
-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_imp
ort_helper
import _pywrap_tensorflow_internal
ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
I also tried installing it like so:
pip install tensorflow
But this did not even install tensorflow; it gives the following error:
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
Please suggest what's the problem and how to solve it.
This is one of the questions posted on Tensorflow installation page under Common Installation Problems section, maybe you can try the solutions provided in the linked SO question.
As for pip installation not working, maybe you should try: python -m pip install tensorflow.
Hope this helps.

Not able to install requests on cygwin - ImportError: No module named _io

When I try the following command
pip install requests
I am getting the following error
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2307, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2013, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py", line 8, in <module>
import zipfile
File "/usr/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/usr/lib/python2.7/io.py", line 60, in <module>
import _io
ImportError: No module named _io
But when I tried to check the env using the following command
env python
I could see that it is running from python 2.7 only
Python 2.7.3 (default, Dec 18 2012, 13:50:09)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
So in the interactive command line I tried the following
>>> import _io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named _io
It is probably because your Anti-Virus program deleted io.py. I just had to reinstall python on cygwin and try installing the program with the Anti-Virus turned off. I successfully installed request this way.
Your pip has broken or conflict with two package installation easy_install vs pip.
1) upgrade or re install with easy_install pip
will solve the problem, if you have other issue with your virtual env due to 14.04 upgrade then look at the question here.similar stackoverflow question

Categories