简体   繁体   English

Python 在 Anaconda 提示符下工作,但不在命令提示符下

[英]Python is working in Anaconda prompt but not in command prompt

I have installed Anaconda and I have used it several time.我已经安装了 Anaconda 并且我已经使用过它好几次了。 However now I want to install Pyspark and it asked me to verify if I have coherent version of java and python installed on my computer.但是现在我想安装 Pyspark,它要求我验证我的计算机上是否安装了一致的 java 和 python 版本。 So, I used command prompt.所以,我使用了命令提示符。 Unfortunately, everything is ok for java but for python: when I have written python --version it opened for me a new window to install python.不幸的是,Java 一切正常,但对于 python:当我编写 python --version 时,它为我打开了一个新窗口来安装 python。

I can not understand how to handle the communication between Anaconda prompt and command prompt.我无法理解如何处理 Anaconda 提示符和命令提示符之间的通信。

After reading many answers I found this solution:在阅读了许多答案后,我找到了这个解决方案:

1- Create my env using the next instruction : 1- 使用下一条指令创建我的环境:

conda create -n Spark python=3.8 ipykernel jupyter anaconda

2- The second step was : activating my env using: 2- 第二步是:使用以下方法激活我的环境:

activate Spark 

Here my env named Spark than after executing the last instruction I got this on my anconda prompt :在这里,我的 env 命名为 Spark,而不是在执行最后一条指令后,我在 anconda 提示符下得到了这个:

3- The 3rd step is to execute : 3- 第三步是执行:

ipython kernel install --name Spark --user

In this case if I run python from my anconda prompt and execute :在这种情况下,如果我从 anconda 提示符运行 python 并执行:

import sys, os 
print(sys.executable)

And if I open the jupyter notebook and run :如果我打开 jupyter notebook 并运行:

import sys, os 
print(sys.executable)

I will find that I am using the same python.exe我会发现我使用的是同一个 python.exe

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

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