Python web2py“;“无法导入请求”;即使已安装请求

Python web2py“;“无法导入请求”;即使已安装请求,python,python-requests,web2py,Python,Python Requests,Web2py,我正在尝试运行web2py应用程序,其中一个控制器中有以下代码 文件名:default.py 在我当前激活的virtualenv中,我使用pip安装了请求,如下所示 (web2pyenv) PS C:\Users\rajesh\Desktop\code\RealPython-Part2\web2py> pip install requests Requirement already satisfied (use --upgrade to upgrade): requests in c:\u

我正在尝试运行web2py应用程序,其中一个控制器中有以下代码

文件名:default.py

在我当前激活的virtualenv中,我使用pip安装了请求,如下所示

(web2pyenv) PS C:\Users\rajesh\Desktop\code\RealPython-Part2\web2py> pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in c:\users\rajesh\desktop\code\realpython-part2\web2py\web2pyenv\lib\site-packages
Cleaning up...
如果我打开一个pythonshell,我就可以导入请求并执行常规操作

(web2pyenv) PS C:\Users\rajesh\Desktop\code\RealPython-Part2\web2py> python
Python 2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get("http://google.com").status_code
200
>>>
当我尝试访问我的web2py应用程序时,它仍然抛出以下错误

Traceback (most recent call last):
  File "gluon/restricted.py", line 224, in restricted
  File "C:/Users/rajesh/Desktop/code/RealPython-Part2/web2py/start/applications/pulse/controllers/default.py", line 1, in <module>
    import requests
  File "gluon/custom_import.py", line 86, in custom_importer
ImportError: Cannot import module 'requests'
回溯(最近一次呼叫最后一次):
文件“glion/restricted.py”,第224行,受限
文件“C:/Users/rajesh/Desktop/code/RealPython-Part2/web2py/start/applications/pulse/controllers/default.py”,第1行,在
导入请求
文件“glion/custom_import.py”,第86行,在custom_importer中
ImportError:无法导入模块“请求”

有没有关于我做错了什么的提示?

很可能您使用的是Windows二进制版本的web2py。此版本包含自己的Python解释器,因此它不使用您在机器上安装的Python版本(或其任何库)。只要安装了Python,就最好运行web2py版本。从源代码运行时,您将能够导入任何已安装的模块

谢谢你,安东尼。是的,我使用的是windows二进制版本。我将尝试使用源代码版本,但是没有办法在二进制版本中安装和导入新模块吗?嗯,您可以将模块复制到“site packages”目录中,但是如果您安装了Python,我认为没有任何理由在源代码版本上使用Windows二进制(Windows和Mac二进制文件的目的只是为没有安装Python的系统提供一个完全独立的包)。明白了。非常感谢!
Traceback (most recent call last):
  File "gluon/restricted.py", line 224, in restricted
  File "C:/Users/rajesh/Desktop/code/RealPython-Part2/web2py/start/applications/pulse/controllers/default.py", line 1, in <module>
    import requests
  File "gluon/custom_import.py", line 86, in custom_importer
ImportError: Cannot import module 'requests'