Getting Error while running python3 main.py file - pandas

I am getting this error,
/tmp/Python-3.7.5$ python3 main.py
Traceback (most recent call last):
File "main.py", line 3, in <module>
import pandas as pd
File "/home/abc/.local/lib/python3.7/site-packages/pandas/__init__.py", line 51, in <module>
from pandas.core.api import (
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/api.py", line 31, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 65, in <module>
from pandas.core.frame import DataFrame
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 119, in <module>
from pandas.core import algorithms, common as com, generic, nanops, ops
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 112, in <module>
from pandas.io.formats import format as fmt
File "/home/abc/.local/lib/python3.7/site-packages/pandas/io/formats/format.py", line 77, in <module>
from pandas.io.common import stringify_path
File "/home/abc/.local/lib/python3.7/site-packages/pandas/io/common.py", line 3, in <module>
import bz2
File "/usr/local/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
what is the solution?

How did you install your Python? If you've manually built it or used the make command, you might be missing the bz2 library headers.
Try the following...
Centos/Fedora/RHEL:
sudo yum install bzip2-devel
Debian and Ubuntu:
sudo apt-get install libbz2-dev
You'll then either need to rebuild your Python installation or to copy the header in your Python folder, with:
sudo cp /usr/lib/python3.7/lib-dynload/_bz2.cpython-38-x86_64-linux-gnu.so /usr/local/lib/python3.7/

Related

ImportError: DLL load failed while importing _ctypes: The specified module could not be found

Python python-3.9.13-amd64 works well in my windows 10 pro.
after uninstalling 3.9.13 and deleting "C:\Users\Admin\AppData\Local\Programs\Python\Python310\ directory , I have installed python-3.10.9-amd64.
It logs out with error:
Traceback (most recent call last):
File "D:\python\ccdtest1.py", line 7, in <module>
import pandas as pd
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\__init__.py", line 22, in <module>
from pandas.compat import is_numpy_dev as _is_numpy_dev # pyright: ignore # noqa:F401
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\compat\__init__.py", line 18, in <module>
from pandas.compat.numpy import (
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\compat\numpy\__init__.py", line 4, in <module>
from pandas.util.version import Version
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\__init__.py", line 8, in <module>
from pandas.core.util.hashing import ( # noqa:F401
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\util\hashing.py", line 24, in <module>
from pandas.core.dtypes.common import (
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\dtypes\common.py", line 27, in <module>
from pandas.core.dtypes.base import _registry as registry
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\dtypes\base.py", line 24, in <module>
from pandas.errors import AbstractMethodError
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\errors\__init__.py", line 6, in <module>
import ctypes
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ImportError: DLL load failed while importing _ctypes: The specified module could not be found.
Attempts made:
pip uinstalled pandas and installed again.
Using regedit, I added C:\Users\Admin\AppData\Local\Programs\Python\Python310\DLLs\ to path.
I copied libcrypto-1_1.dll,libssl-1_1.dll,libffi-7.dll from C:\Users\Admin\AppData\Local\Programs\Python\Python310\DLLs to my py program directory.
problem remains.
please help.
I found out the issue. There were some .pyd files in my py programs directory. I removed all .pyd, from my py programs directory.
I have installed python 3.11.1 and everything working well now.

How do I run pandas on replit

I have a python code for a discord bot. It is working locally but when I try to run it on replit.com I get this error.
Traceback (most recent call last):
File "main.py", line 2, in <module>
import pandas as pd
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/__init__.py", line 48, in <module>
from pandas.core.api import (
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/api.py", line 48, in <module>
from pandas.core.groupby import (
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.generic import (
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 70, in <module>
from pandas.core.frame import DataFrame
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/frame.py", line 157, in <module>
from pandas.core.generic import NDFrame
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/generic.py", line 152, in <module>
from pandas.core.window import (
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/window/__init__.py", line 1, in <module>
from pandas.core.window.ewm import ( # noqa:F401
File "/home/runner/Animanji/venv/lib/python3.8/site-packages/pandas/core/window/ewm.py", line 12, in <module>
import pandas._libs.window.aggregations as window_aggregations
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
I already installed the packages but didn't work, but it pandas does work on the bash window when I run python3 there.
I couldn't find any solution other than forking another repl and putting my files there.
here is the repl if anyone is interested: https://replit.com/#HourKesh/AppropriateKnobbyInstruction#poetry.lock .
Try going to the replit shell and type pip3 install pandas.

problem in lauching the jupyter notebook from anaconda prompt

I installed tensorflow gpu one day ago at that time it was working fine, but now when I am trying to launch the notebook i am getting following error.
Traceback (most recent call last):
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\notebook\notebookapp.py", line 80, in <module>
from .services.contents.manager import ContentsManager
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\nbformat\__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\nbformat\validator.py", line 12, in <module>
from .json_compat import get_current_validator, ValidationError
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\nbformat\json_compat.py", line 10, in <module>
import jsonschema
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\jsonschema\__init__.py", line 14, in <module>
from jsonschema._format import (
File "C:\Users\sumanta\anaconda3\envs\tf_2.5\lib\site-packages\jsonschema\_format.py", line 240, in <module>
#_checks_drafts(draft7="idn-hostname", raises=idna.IDNAError)
AttributeError: module 'idna' has no attribute 'IDNAError'
A very, very basic solution - but what fixed this a while back for me was pip install idna. Give it a shot.

E: Package 'python3-distutils' has no installation candidate

I am currently using the Google core dev board and using Putty to enter the code.
While performing the code, I got the error as below.
Traceback (most recent call last):
File "tools/generate_detections.py", line 7, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
So I typed sudo pip install tensorflow.
but I got another error as below.
Traceback (most recent call last):
File "/home/mendel/.local/bin/pip", line 6, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/configuration.py", line 27, in <module>
from pip._internal.utils.misc import ensure_dir, enum
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/misc.py", line 42, in <module>
from pip._internal.locations import get_major_minor_version, site_packages, user_site
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/locations/__init__.py", line 14, in <module>
from . import _distutils, _sysconfig
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/locations/_distutils.py", line 9, in <module>
from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'
So I typed sudo apt install python3-distutils.
but I got another error as below.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3-distutils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libpython3.7-stdlib
E: Package 'python3-distutils' has no installation candidate
I can no longer find a solution.
Is there anyone who can help me?
sudo apt install python3-distutils
Just install in your Ubuntu terminal after you can install other packages!

ImportError: object file libiconv.so.2 missing

I was trying out QuotesSpider example given in docs (page# 5, here), but am having a hard time to get it running. I installed scrapy from conda in the root environment. I am on Ubuntu 14.04, 64 bit machine. As soon as I run the given code snippet with the following command:
$ scrapy runspider quotes_spider.py -o quotes.json
I get the following error:
Traceback (most recent call last):
File "/home/rip/miniconda2/bin/scrapy", line 4, in <module>
import scrapy.cmdline
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/__init__.py", line 34, in <module>
from scrapy.spiders import Spider
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
from scrapy.http import Request
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html
File "/home/rip/miniconda2/lib/python2.7/site-packages/lxml/html/__init__.py", line 54, in <module>
from .. import etree
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory
As apparent, an object file seems to be missing. Do I have to build scrapy from source, or is there an alternative?