How-To: Using VS Code as IDE in Conda Environment for Python and R Development - Mac

Summary

Using VS Code as Integrated Development Environment (IDE) in Conda Environment for Python and R Development - Mac

Body

Question

How do I use VS Code as the integrated development environment (IDE) in a conda environment for Python and R development on a Mac?

 

Answer

Note:  Miniconda should already be installed, see "How-To: Install Miniconda Without Administrator Privileges on a Mac

 

Note:  VS Code should already be installed from Software Center, see "How To: Access Software Center in Mac OS

 

1. Using Terminal, create conda environment for use with R, enter "conda create -n <env-name> -c conda-forge r-base r-essentials r-languageserver".

Example environment: r_env_t4

How-To: Rstudio: Create Conda Environment for Using Rstudio

 

2. Activate new conda environment, enter "conda activate <env-name>".

Example environment: r_env_t4

How-To: Using Anaconda - Activate a Virtual Conda Environment via Command Line Interface

 

3. Add VS Code path to launch VS Code in activated conda environment, enter the below.

cat << EOF >> ~/.zprofile               

# Add Visual Studio Code (code)

export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

EOF

 

4. Load file created in step 3, enter "source ~/.zprofile".

 

5. Launch VS Code from the terminal, enter "code".

terminal with activated conda environment, "code" entered on command line

 

6. In VS Code, install Python extension by Microsoft.

a. Select Extensions icon.

b. Enter "python" in Extensions: Marketplace search box.

c. Select "Install" for the Python language support... by Microsoft.

VS Code left extensions list pane with python extension highlighted.

 

7. Install R extension by REditorSupport.

a. Enter "R" in Extensions: Marketplace search box.

b. Select "Install" for the R Extension for Visual Studio Code by REditorSupport.

VS Code left extensions list pane with R extension highlighted.

 

8. Extensions installed.

VS Code left extensions list pane with extensions installed.

 

9.  Create new project folder.

a. Select Explorer icon.

b. Create new project folder.

c. Enter new project folder name.

VS Code explorer pane with new project folder
 

10. Create a new R file in project directory

VS Code explorer pane with new file. 

 

11. Add command print("Hello!") to new file.

12. Run file to verify R integration.

VS Code center file pane with "print("Hello!")" command.

 

13. Verify operation and integration.

a. Confirm output "Hello!".

b. Confirm R version is displayed.

c. Enter R.home() and confirm result path is within active conda environment.

Example: /Users/<username>/miniconda3/envs/r_t4_env/lib/R

VS Code terminal window with print command output, R.home() command results, and R version in footer highlighted.

 

 

 

For Additional Assistance

 

https://code.visualstudio.com/docs/languages/r

Details

Details

Article ID: 2548
Created
Wed 6/17/26 10:52 AM
Modified
Thu 7/9/26 10:03 AM