简体   繁体   English

Python无法找到已安装的模块

[英]Python can't find installed modules

I've used these modules before, even in a Python script inside a folder where I have other working scripts. 我以前使用过这些模块,甚至在我有其他工作脚本的文件夹中的Python脚本中也使用过。 Here's my imports: 这是我的进口商品:

import os
import sys    
import urllib.request as urllib, simplejson as json, requests
import subprocess
import Popen, PIPE
import time

I get this in my console: 我在控制台中得到这个:

Traceback (most recent call last):
  File "party.py", line 4, in <module>
    import urllib.request as urllib, simplejson as json, requests
ImportError: No module named request

How come? 怎么会? I've tried 我试过了

sudo pip install request

..but with no luck. ..但没有运气。 What is causing this? 是什么原因造成的?

what python version are you using? 您正在使用什么python版本? urllib.request seems to be python3 urllib.request似乎是python3

v2.7 v2.7

>>> import urllib.request
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named request
>>> 

v3.3 v3.3

>>> import urllib.request
>>> urllib.request
<module 'urllib.request' from '/usr/lib/python3.3/urllib/request.py'>
>>> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM