Use the Default Python Rather Than the Anaconda Installation When Called from the Terminal

Use the default Python rather than the Anaconda installation when called from the terminal

Anaconda adds the path to your .bashrc, so it is found first. You can add the path to your default Python instance to .bashrc or remove the path to Anaconda if you don't want to use it.

You can also use the full path /usr/bin/python in Bash to use the default Python interpreter.

If you leave your .bashrc file as is, any command you run using python will use the Anaconda interpreter. If you want, you could also use an alias for each interpreter.

You will see something like export PATH=$HOME/anaconda/bin:$PATH in your .bashrc file.

So basically, if you want to use Anaconda as your main everyday interpreter, use the full path to your default Python or create an alias. If you want it the other way around, remove the export PATH=.... from bashrc and use full path to Anaconda Python interpreter.

How to change cmd python from anaconda to default python?

Set the environment path variable of your default python interpreter in system properties.

or if this doesn't work do:

in cmd C:\Python27\python.exe yourfilename.py

in the command first part is your interpreter location and second is your file name

Why can't Python find the module I installed?

You have 2 versions of Python:

  1. Default Python (used everytime you open your command prompt and type python or python3)
  2. Anaconda is installing packages in a virtual environment, using it's own Python (it is located in a different path)

You can see the path of your installed python using python -c "import os, sys; print(os.path.dirname(sys.executable))"

You have 2 Options:

  1. Configure the PyCharm in order to use the anaconda Python. https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#view_list
  2. Open a command prompt in the project's folder (you can do it easily using PyCharm). Type conda env list. This will show you all available anaconda virtual environments. Choose 1 of them and type conda activate <env_name>, where <env_name>=the name of the environment. Then, run your program using python <name_of_your_program>

You can see the paths where the anaconda environments and packages are installed using conda info

Working with Anaconda in Visual Studio Code

Activating a conda environment does not place conda on your PATH. You need to launch the Anaconda Prompt app from your Start menu to get a command-line with conda on your PATH if you didn't check the box to include conda during installation.

Also realize that conda only supports PowerShell as of conda 4.6 which was released in January 2019.

And the Python extension for VS Code works with conda fine. Create a conda environment and the extension will allow you to select it as your environment/interpreter.



Related Topics



Leave a reply



Submit