Same Interpreter(?), Different Package Version in Spyder

爱⌒轻易说出口 提交于 2019-12-11 09:17:42

问题


I got this import error, which as this answer indicates occurs because the requests package is out of date. I updated the package using pip, but still got the same error. So I tried from requests.utils import to_native_string, which to my surprise works just fine in either the command prompt shell or IDLE, but throws an error in Spyder. I checked the version of the requests package:

import requests
print(requests.__version__)

The version number in Spyder ('1.2.3') is indeed different from the version number in IDLE or the cmd shell ('2.7.0'). I am a loss to explain why this would be the case, however, because Spyder points to the same interpreter at C:\Python27\python.exe and if I check the version of python being used:

import sys
print(sys.version)

I get the same result everywhere: '2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]'.


回答1:


I would check out two different possible issues:

1) Make sure that the .pyc file of the module that is importing requests is deleted - I believe there is a setting in Spyder to ensure the interpreter gets reloaded each time called the UMD?

2) Even though the interpreter is specified, make sure that the site-packages that Spyder is using is also specified.

It is possible that when Spyder was installed, it created a virtual env that copied the contents of the system site-packages at the time of installation. While you may be updating the system packages, perhaps the virtual env that Spyder is looking at is not being updated?



来源:https://stackoverflow.com/questions/30878697/same-interpreter-different-package-version-in-spyder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!