我在导入
pandas
包时遇到问题。我使用以下命令导入它:
import pandas as pd
但是,我收到以下错误消息:
Traceback (most recent call last):
Cell In[54], line 1
import pandas as pd
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\__init__.py:48
from pandas.core.api import (
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\api.py:27
from pandas.core.arrays import Categorical
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arrays\__init__.py:1
from pandas.core.arrays.arrow import ArrowExtensionArray
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arrays\arrow\__init__.py:1
from pandas.core.arrays.arrow.array import ArrowExtensionArray
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arrays\arrow\array.py:60
from pandas.core.arraylike import OpsMixin
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\arraylike.py:21
from pandas.core.ops.common import unpack_zerodim_and_defer
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\ops\__init__.py:38
from pandas.core.ops.array_ops import (
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py:57
from pandas.core.computation import expressions
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\computation\expressions.py:20
from pandas.core.computation.check import NUMEXPR_INSTALLED
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\core\computation\check.py:5
ne = import_optional_dependency("numexpr", errors="warn")
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\compat\_optional.py:157 in import_optional_dependency
version = get_version(module_to_get)
File ~\AppData\Local\anaconda3\lib\site-packages\pandas\compat\_optional.py:84 in get_version
raise ImportError(f"Can't determine version for {module.__name__}")
ImportError: Can't determine version for numexpr
我正在使用以下版本的Python:
Python 3.10.10 | packaged by Anaconda, Inc. | (main, Mar 21 2023, 18:39:17) [MSC v.1916 64 bit (AMD64)]
有什么办法可以解决这个问题吗?
一些重要信息可能是这台计算机可以通过 VPN 远程访问我正在使用的服务器。所以我只能在登录 VPN 时才能访问该程序。
如果你使用的是ubuntu linux,你可以尝试
sudo apt-get install python-numexpr
。请参考这个答案 - https://askubuntu.com/questions/446644/why-do-i-get-importerror-when-trying-to-import-pandas-python-module
安装numexpr和bottleneck后,您可以尝试
pip install --force-reinstall pandas
或pip install --upgrade --force-reinstall pandas
以确保pandas安装正确。
NAME:"Kali GNU/Linux"
VERSION_ID:"2023.4"
VERSION:"2023.4"
PYTHON_VERSION:"3.11.6"
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
datasets = [11, 17, 16, 15, 14, 13, 12, 256, 255, 250]
dataset=sorted(datasets)
print(f"Sorted Dataset: {dataset}")
q1,q3=np.percentile(dataset,[25,75])
print(f"Q1: {q1}, Q3: {q3}")
iqr=q3-q1
print(f"IQR: {iqr}")
lower_fence=q1-(1.5*iqr)
upper_fence=q3+(1.5*iqr)
print(f"Lower Fence: {lower_fence}, Upper Fence: {upper_fence}")
sns.boxplot(datasets)
plt.show()
Traceback (most recent call last):
File "/home/jatin/ds/3.py", line 3, in <module>
import seaborn as sns
File "/home/jatin/.local/lib/python3.11/site-packages/seaborn/__init__.py", line 2, in <module>
from .rcmod import * # noqa: F401,F403
^^^^^^^^^^^^^^^^^^^^
File "/home/jatin/.local/lib/python3.11/site-packages/seaborn/rcmod.py", line 5, in <module>
from . import palettes
File "/home/jatin/.local/lib/python3.11/site-packages/seaborn/palettes.py", line 9, in <module>
from .utils import desaturate, get_color_cycle
File "/home/jatin/.local/lib/python3.11/site-packages/seaborn/utils.py", line 11, in <module>
import pandas as pd
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/__init__.py", line 49, in <module>
from pandas.core.api import (
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/api.py", line 28, in <module>
from pandas.core.arrays import Categorical
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/arrays/__init__.py", line 1, in <module>
from pandas.core.arrays.arrow import ArrowExtensionArray
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/arrays/arrow/__init__.py", line 5, in <module>
from pandas.core.arrays.arrow.array import ArrowExtensionArray
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/arrays/arrow/array.py", line 50, in <module>
from pandas.core import (
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/ops/__init__.py", line 8, in <module>
from pandas.core.ops.array_ops import (
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 56, in <module>
from pandas.core.computation import expressions
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/computation/expressions.py", line 21, in <module>
from pandas.core.computation.check import NUMEXPR_INSTALLED
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/core/computation/check.py", line 5, in <module>
ne = import_optional_dependency("numexpr", errors="warn")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/compat/_optional.py", line 150, in import_optional_dependency
version = get_version(module_to_get)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jatin/.local/lib/python3.11/site-packages/pandas/compat/_optional.py", line 78, in get_version
raise ImportError(f"Can't determine version for {module.__name__}")
ImportError: Can't determine version for numexpr
pip install numexpr
pip install bottleneck