安装rdflib时找不到路径

0 投票
2 回答
1304 浏览
提问于 2025-04-17 16:35

当我设置的时候,我收到了:

C:\Python27>python Lib\site-packages\rdflib-master\setup.py
Traceback (most recent call last):
    File "Lib\site-packages\rdflib-master\setup.py", line 64, in <module>
        version = find_version('rdflib/__init__.py')
    File "Lib\site-packages\rdflib-master\setup.py", line 59, in find_version
        for line in open(filename):
IOError: [Errno 2] No such file or directory: 'rdflib/__init__.py'

文件是存在的,我也试着把包的路径加到PYTHONPATH里,但还是不行。

于是我尝试使用ez_setup.py,但它在某个网址上出错,显示404(下面有详细信息)。

我也搜索了一些通用的安装建议:我找到了本科和研究生的内容,但没有什么能帮到我。

Downloading http://cheeseshop.python.org/packages/2.7/s/setuptools/setuptools-0.6c5-py2.7.egg
Traceback (most recent call last):

  File "Lib\site-packages\rdflib-master\ez_setup.py", line 223, in <module>
    main(sys.argv[1:])

  File "Lib\site-packages\rdflib-master\ez_setup.py", line 155, in main
    egg = download_setuptools(version, delay=0)

  File "Lib\site-packages\rdflib-master\ez_setup.py", line 137, in download_setuptools
    src = urllib2.urlopen(url)

  File "C:\Python27\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)

  File "C:\Python27\lib\urllib2.py", line 400, in open
    response = meth(req, response)

  File "C:\Python27\lib\urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)

  File "C:\Python27\lib\urllib2.py", line 432, in error
    result = self._call_chain(*args)

  File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
    result = func(*args)

  File "C:\Python27\lib\urllib2.py", line 619, in http_error_302
    return self.parent.open(new, timeout=req.timeout)

  File "C:\Python27\lib\urllib2.py", line 400, in open
    response = meth(req, response)

  File "C:\Python27\lib\urllib2.py", line 513, in http_response
    'http', request, response, code, msg, hdrs)

  File "C:\Python27\lib\urllib2.py", line 438, in error
    return self._call_chain(*args)

  File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
    result = func(*args)

  File "C:\Python27\lib\urllib2.py", line 521, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

2 个回答

0

把源代码放到 Lib\site-packages 这个地方听起来有点奇怪,但如果你想从源代码安装的话,你需要在源代码的文件夹里运行 setup.py 这个文件。它会报错说 rdflib/__init__.py 这个文件不存在,因为确实没有这个文件:要注意,这里的路径是相对的。

0

我们需要更多的信息,抱歉哦。你用的是哪个版本的RDFLib?你是怎么尝试安装的?能把完整的错误信息发给我们吗?

最好的方法是使用“pip”来安装,具体可以参考这个链接:http://www.pip-installer.org/en/1.3.X/installing.html

然后执行下面的命令:

pip install rdflib

这样就能安装最新的RDFLib 3.2.X版本了!

撰写回答