gpt4 book ai didi

python - 导入 pandas.DataFrame 时获取 "IOError: [Errno 13] Permission denied:.."

转载 作者:太空狗 更新时间:2023-10-29 20:43:48 26 4
gpt4 key购买 nike

我得到了

IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/top_level.txt'

当我尝试导入 Pandas 时。我不明白为什么。在 python3 控制台中导入 pandas 就可以了。代码的执行也是用 Python3 完成的

start_simulation.py

from Market import Market
from TestingAlgorithm import TestingAlgorithm
from LiteForexHandler import LiteForexHandler
from Broker import Broker
from Portfolio import Portfolio

market = Market('./simulations/', 'test', TestingAlgortihm, LiteForexHandler,
Broker, Portfolio)
market.run()`

LiteForexHandler.py 的开始:

import sqlite3 as lite
from pandas import DataFrame
from DataHandler import DataHandler
import logging as log
from collections import defaultdict
...

最后是 Traceback

Traceback (most recent call last):
File "start_simulation.py", line 3, in <module>
from LiteForexHandler import LiteForexHandler
File "/home/ioan/Dokumente/finance/stocker/LiteForexHandler.py", line 2, in <module>
from pandas import DataFrame
File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.1_501_g4c3b9e5-py2.7-linux-x86_64.egg/pandas/__init__.py", line 38, in <module>
import pandas.core.config_init
File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.1_501_g4c3b9e5-py2.7-linux-x86_64.egg/pandas/core/config_init.py", line 17, in <module>
from pandas.core.format import detect_console_encoding
File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.1_501_g4c3b9e5-py2.7-linux-x86_64.egg/pandas/core/format.py", line 9, in <module>
from pandas.core.index import Index, MultiIndex, _ensure_index
File "/usr/local/lib/python2.7/dist-packages/pandas-0.13.1_501_g4c3b9e5-py2.7-linux-x86_64.egg/pandas/core/index.py", line 11, in <module>
import pandas.index as _index
File "index.pyx", line 34, in init pandas.index (pandas/index.c:15559)
File "/usr/local/lib/python2.7/dist-packages/pytz-2014.2-py2.7.egg/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2823, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 710, in subscribe
callback(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2823, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2255, in activate
self.insert_on(path)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2362, in insert_on
self.check_version_conflict()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2401, in check_version_conflict
for modname in self._get_metadata('top_level.txt'):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2249, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1219, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1211, in get_metadata
return self._get(self._fn(self.egg_info,name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1326, in _get
stream = open(path, 'rb')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/top_level.txt'

最佳答案

这是 python-dateutil 的一个已知问题,其中 pypi 包中的权限设置不正确:https://bugs.launchpad.net/dateutil/+bug/1243202 .这不是 pip 的问题,因为 pip 规范化了权限,但如果您以不同的方式安装它,您可能会遇到问题。

简单的解决方案是运行

sudo chmod o+r /usr/local/lib/python2.7/dist-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/top_level.txt

对 dist-packages 目录中遇到此问题的任何其他文件执行相同的命令。

关于python - 导入 pandas.DataFrame 时获取 "IOError: [Errno 13] Permission denied:..",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22736014/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com