开发者

how to import the new installed module whie an old same module exists

everybody!

the built-in pycurl module doesn't define Curl object

conn = pycurl.Curl()

Error message:

"pycurl" module has no attribute Curl

so I download the latest pycurl and install it,but it only works when I ran the code in interactive python interpreter,and I got the same error when I ran it as a script file.

It seems that when I run it as a script file,the old pycurl module will be included.

How can I import the new pycurl module or remove开发者_C百科 the old pycurl module?Thanks in advance.

PS.

in pydoc,the pycurl(old) module under '.' is clickable,redirecting to a page only saying "module has no attribute Curl",while the one(new) under '/usr/local/lib/python2.7/dist-packages' is gray and unclickable


It's a matter of when it is found. The basic import handler used in Python looks at the paths specified in sys.path in order to find a module, and after it has found something matching pycurl it will use it and not look further.

So, you need to either put your own copy of pycurl higher in the module search path, or in your own script do something like sys.path.insert(1, '/path/to/my-pycurl') with the path to the directory containing the pycurl package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜