Python 导入 web 不起作用

发布于 2025-01-06 05:44:06 字数 1758 浏览 1 评论 0原文

因此,在运行导入 web 的脚本时,我收到以下错误。

$ python bin/app.py
Traceback (most recent call last):
File "bin/app.py", line 1, in <module>
import web
ImportError: No module named web

我尝试使用 easy_install web 但收到此错误:

$ easy_install web
Searching for web
Reading http://pypi.python.org/simple/web/
Reading http://www.pythonweb.org/web/
Reading http://www.pythonweb.org/web/release/
No local packages or download links found for web
error: Could not find suitable distribution for Requirement.parse('web')

我尝试 pip install web 但收到以下错误:

$ pip install web
Downloading/unpacking web
Could not find any downloads that satisfy the requirement web
No distributions at all found for web
Storing complete log in /Users/zcj90/.pip/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.0.2', 'console_scripts', 'pip')()
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/__init__.py", line 116, in main
return command.main(initial_args, args[1:], options)
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/basecommand.py", line 151, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/basecommand.py", line 180, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/Users/zcj90/.pip/pip.log'

有什么建议吗?

app.py 的代码:

import web

urls = (
    '/', 'index'
)
app = web.application(urls, globals())
class index:
    def GET(self):
        greeting = "Hello World"
        return greeting
if __name__ == "__main__":
    app.run()*

So I'm getting the following error when running a script that imports web.

$ python bin/app.py
Traceback (most recent call last):
File "bin/app.py", line 1, in <module>
import web
ImportError: No module named web

I tried using easy_install web but get this error:

$ easy_install web
Searching for web
Reading http://pypi.python.org/simple/web/
Reading http://www.pythonweb.org/web/
Reading http://www.pythonweb.org/web/release/
No local packages or download links found for web
error: Could not find suitable distribution for Requirement.parse('web')

And I tried pip install web but get the following:

$ pip install web
Downloading/unpacking web
Could not find any downloads that satisfy the requirement web
No distributions at all found for web
Storing complete log in /Users/zcj90/.pip/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.0.2', 'console_scripts', 'pip')()
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/__init__.py", line 116, in main
return command.main(initial_args, args[1:], options)
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/basecommand.py", line 151, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg/pip/basecommand.py", line 180, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/Users/zcj90/.pip/pip.log'

Any suggestions?

Code for app.py:

import web

urls = (
    '/', 'index'
)
app = web.application(urls, globals())
class index:
    def GET(self):
        greeting = "Hello World"
        return greeting
if __name__ == "__main__":
    app.run()*

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

你怎么敢 2025-01-13 05:44:06

的命令

以下是您需要运行$ easy_install web.py

,并且根据 lpthw 的文档(仅使用 web.py 的分支),您可以运行:

$ pip install lpthw.web

然后运行您的应用程序只需要做:

$ python app.py

The following is the command that you need to run

$ easy_install web.py

And according to the document for lpthw (which just uses a fork of web.py), you can run :

$ pip install lpthw.web

Then to run the application you will just need to do:

$ python app.py

夏尔 2025-01-13 05:44:06

老问题,但对于通过网络搜索到达此问题的人来说,这就是您正在寻找的命令,假设有一个基于 apt 的 Linux 发行版,如 ubuntu 或 debian:

$ sudo aptitude install python-webpy

Old question, but for people who reach this via web search, this is the command you're looking for, assuming an apt-based linux distribution like ubuntu or debian:

$ sudo aptitude install python-webpy

余生共白头 2025-01-13 05:44:06

您必须从 http://webpy.org/static/web.py 下载源代码-0.36.tar.gz

安装 Web 的步骤位于 http://webpy.org/install

如果出现任何错误,请按照步骤操作,然后向本文添加评论或更新问题。

You have to download source from http://webpy.org/static/web.py-0.36.tar.gz.

The steps to install web is on http://webpy.org/install.

Please follow the steps if got any error then add comments to this post or update the question.

万人眼中万个我 2025-01-13 05:44:06

Pythonweb 已经过时了,但他们仍然有下载页面,您可以在其中可以获得最新版本。然后只需执行python setup.py install

Pythonweb is pretty out of date, but they still have a downloads page where you can get the most recent release. Then just do a python setup.py install

作死小能手 2025-01-13 05:44:06

对于 Ubuntu 操作系统,使用以下命令安装 python web:

sudo apt-get install python-webpy

For Ubuntu OS, install python web using below command:

sudo apt-get install python-webpy
月光色 2025-01-13 05:44:06

使用 pip:pip install web.py==0.40.dev0

With pip: pip install web.py==0.40.dev0

千寻… 2025-01-13 05:44:06

问题是您很可能使用 pip install lpthw.web 来安装,但是 lpthw 书使用的是 python 2.7,因此 pip2.7 可以修复这个:

pip2.7安装lpthw.web

The problem is that you most likely used pip install lpthw.web to install however the lpthw book is using python 2.7 so pip2.7 would fix this:

pip2.7 install lpthw.web

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文