简体   繁体   English

Win10上的两个python3解释器引起误解

[英]Two python3 interpreters on win10 cause misunderstanding

I used win10. 我用win10。 When I installed Visual Studio2017, I configure the Python3 environment. 安装Visual Studio2017时,我配置了Python3环境。 And then after half year I installed Anaconda(Python3) in another directory. 然后半年后,我在另一个目录中安装了Anaconda(Python3)。 Now I have two interpreters in different directories. 现在,我在不同目录中有两个解释器。

Now, no matter in what IDE I code the codes, after I save it and double click it in the directory, the Python File is run by the interpreter configured by VS2017. 现在,无论我在哪种IDE中编写代码,在将其保存并双击目录后,Python文件都将由VS2017配置的解释器运行。

Why do I know that? 我怎么知道 I use sys.path to get to know it. 我使用sys.path来了解它。 But when I use VS2017 to run the code, it shows no mistake. 但是当我使用VS2017运行代码时,它没有显示任何错误。 The realistic example is that I pip install requests in cmd, then I import it in a Python File. 实际的示例是,我在cmd中插入安装请求 ,然后导入 Python文件中。 Only when I double click it, the Traceback says I don't have this module. 仅当我双击它时, Traceback才会说我没有此模块。 In other cases it works well. 在其他情况下,它运作良好。

So, how to change the default python interpreter of the cmd.exe? 那么,如何更改cmd.exe的默认python解释器?

Just change the interpreter order of the python in the PATH is enough. 只需在PATH中更改python的解释器顺序就足够了。
If you want to use python further more, I suggest you to use virtual environment tools like pipenv to control your python interpreters and modules. 如果您想进一步使用python,建议您使用虚拟环境工具(例如pipenv来控制python解释器和模块。

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

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