【发布时间】:2019-04-18 10:45:18
【问题描述】:
Exception has occurred: ModuleNotFoundError
No module named 'requests'.
但请求位于:C:\Users\piotr\Environments\bitcoin_notifications\Lib\site-packages\requests
我输入了 pip install requests 以将它们安装到我的 venv 中。
(bitcoin_notifications) PS C:\Users\piotr> pip install requests
Collecting requests
Downloading https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a6777857kB)
100% |████████████████████████████████| 61kB 868kB/s
Collecting certifi>=2017.4.17 (from requests)
Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d5s/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd2.py3-none-any.whl (158kB)731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.w2MB/shl (158kB)
100% |████████████████████████████████| 163kB 2.s/bc/a9/01ffebfb562e4274b6487b4bb1dd2MB/s y3-none-any.whl (133kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests) 5MB/s
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22s/14/2c/cd551d81dbe15200be1cf41cd038e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl ne-any.whl (58kB)
(133kB) MB/s
100% |████████████████████████████████| 143kB 1.5MB/s s/df/1c/59cca3abf96f991f2ec3131a4ffeCollecting idna<2.9,>=2.5 (from requests)
Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)69a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB) 100% |████████████████████████████████| 61kB 2.4MB/s
我导入请求:import requests
还有:
Exception has occurred: ModuleNotFoundError
No module named 'requests'
File "C:\Users\piotr\Documents\bitcoin_notifications.py", line 1, in <module>
import requests
File "C:\Users\piotr\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\piotr\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\piotr\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
【问题讨论】:
-
您的请求似乎在
virtualenv中,但错误似乎表明您正在系统python 中尝试import requests。在尝试import requests之前您是否激活了virtualenv -
你能告诉我们产生这些错误的命令吗?有很多可能性...
-
PS C:\Users\piotr> Environments\bitcoin_notifications\Scripts\activate (bitcoin_notifications) PS C:\Users\piotr> -
当我再次调试时,Python 控制台作为第二个终端打开并且:
ppcd : The term 'ppcd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
标签: python python-3.x python-requests virtualenv python-venv