======================================= Configure Coding Environment on Windows ======================================= 1. Install Anaconda and Launch Anaconda Prompt ------------------------------------------------ - **Download and Install Anaconda:** Visit the `Anaconda Distribution page `_ and download the Windows installer. Follow the installation instructions. - **Launch Anaconda Prompt:** Open the Windows Start Menu, search for **Anaconda Prompt**, and open it. 2. Create a Conda Environment with Python 3.12 ----------------------------------------------- - **Create the Environment:** In the Anaconda Prompt, run:: conda create -n vpsc python=3.12 This command creates a new environment named *vpsc* using Python 3.12. - **Activate the Environment:** Activate your new environment with:: conda activate vpsc 3. Install Git for Windows --------------------------- - **Download Git for Windows:** Go to the `Git for Windows website `_ and download the installer. - **Install Git:** Run the installer with the default options (or adjust as needed). 4. Launch Git Bash and Setup Repository Directory --------------------------------------------------- - **Open Git Bash:** After installing Git, open **Git Bash** from the Start Menu. - **Create a Folder for Your Repositories:** In Git Bash, run:: mkdir -p ~/git cd ~/git This creates a directory named *git* in your home folder (i.e., ~/) and moves you into it. 5. Clone Your GitHub Repository -------------------------------- - **Clone the Repository:** From Git Bash (while in your ``~/git`` directory), run:: git clone https://github.com/jackweeks8/vpsc.git This will clone your repository into a folder named *vpsc*. 6. Install Your Package in Editable Mode ----------------------------------------- - **Navigate to the Repository Directory:** In the Anaconda Prompt (with the *vpsc* environment activated), change to your repository folder. For example:: cd C:\Users\YourName\git\vpsc *(Replace with your actual path.)* - **Install in Editable Mode:** Run:: pip install -e . This installs your package in "editable" mode, so changes to your source code are immediately reflected. 7. Install IPython and Test the Example ----------------------------------------- - **Install IPython:** With your environment activated, run:: pip install ipython - **Launch IPython:** Start IPython by running:: ipython - **Test Your Function:** In the IPython session, try importing and running your example:: from vpsc.skeleton import fib print(fib(10)) This should execute the ``fib`` function as defined in your package. 8. Update Spyder in the Base Environment and Configure It to Use the vpsc Kernel -------------------------------------------------------------------------------- Due to compatibility issues with reconfiguring Spyder’s interpreter, update your base Spyder to the latest version and connect it to the *vpsc* environment using its kernel. - **Update Spyder in the Base Environment:** In the Anaconda Prompt (with your base environment activated), update Spyder by running:: conda update spyder - **Install spyder-kernels in the vpsc Environment:** Activate your *vpsc* environment and install spyder-kernels:: conda activate vpsc pip install spyder-kernels - **Launch Base Spyder:** Start the base Spyder (from the base environment). It should now be up to date and compatible with connecting to an external kernel. - **Configure Spyder to Use the vpsc Kernel:** In Spyder, navigate to **Tools → Preferences → Python interpreter**. Set the option to use an external kernel by specifying the following interpreter:: C:\Users\YourName\anaconda3\envs\vpsc\python.exe *(Replace with the actual path to your *vpsc* environment’s Python executable.)* Click **Apply** and **OK**; then restart Spyder. - **Verify the Configuration:** Open an IPython Console inside Spyder and run:: from vpsc.skeleton import fib print(fib(10)) If the import works and the example runs, Spyder is correctly connected to the *vpsc* environment. 9. Configure VSCode Environment --------------------------------- - **Install VSCode:** Download and install Visual Studio Code from the `VSCode website `_. - **Install the Python Extension:** Open VSCode, go to the Extensions view by clicking on the square icon on the sidebar or pressing ``Ctrl+Shift+X``, and search for *Python*. Install the official Python extension provided by Microsoft. - **Configure the Python Interpreter:** Open the Command Palette (``Ctrl+Shift+P``) and type ``Python: Select Interpreter``. Select the interpreter located at:: C:\Users\YourName\anaconda3\envs\vpsc\python.exe *(Replace with the actual path to your *vpsc* environment’s Python executable.)* - **Open Your Project Folder:** In VSCode, select **File → Open Folder** and navigate to your repository folder (e.g., ``C:\Users\YourName\git\vpsc``). - **Configure the Integrated Terminal:** VSCode can use the Anaconda Prompt or Git Bash as the integrated terminal. To configure, open **File → Preferences → Settings** and search for ``terminal.integrated.shell.windows``. Set the path to your preferred terminal (e.g., Git Bash: ``C:\Program Files\Git\bin\bash.exe`` or Anaconda Prompt). - **(Optional) Create VSCode Workspace Settings:** Create a ``.vscode`` folder in your project directory with a ``settings.json`` file containing the following configuration:: { "python.pythonPath": "C:\\Users\\YourName\\anaconda3\\envs\\vpsc\\python.exe", "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe" } *(Update the paths as necessary.)* - **Setup Windows Subsystem for Linux (WSL) Integration (Optional):** - **What is WSL?** WSL (Windows Subsystem for Linux) is a compatibility layer that enables you to run a Linux environment directly on Windows without the overhead of a virtual machine. It is useful for leveraging Linux-specific tools and workflows. - **Why Use WSL?** Using WSL in VSCode allows you to develop and test code in a Linux environment while still working within Windows. It is particularly helpful if your project targets a Linux deployment or if you prefer Linux command-line utilities. - **How to Set Up WSL:** 1. **Install WSL:** Open PowerShell as an administrator and run:: wsl --install This command installs WSL along with a default Linux distribution (usually Ubuntu). You may need to restart your computer. 2. **Install the Remote - WSL Extension in VSCode:** In VSCode, go to the Extensions view (``Ctrl+Shift+X``) and search for *Remote - WSL*. Install the extension provided by Microsoft. 3. **Open a WSL Window in VSCode:** Open the Command Palette (``Ctrl+Shift+P``), type ``Remote-WSL: New Window``, and press Enter. VSCode will open a new window connected to your WSL environment. 4. **Access Your Project in WSL:** In the WSL window, open your project folder by selecting **File → Open Folder** and navigating to the location of your project (or mounting your Windows drive if necessary). 5. **Configure the Python Interpreter in WSL:** Once in the WSL environment, open the Command Palette, choose ``Python: Select Interpreter``, and select the appropriate Python interpreter (which might be in your WSL installation or the one from your Anaconda environment if configured accordingly). - **Test the Configuration:** Open a new terminal in VSCode to ensure that the correct environment is activated. Then, create a new Python file or open an existing one and run your code to verify that VSCode uses the *vpsc* environment (or WSL if configured). Summary ======= - **Anaconda Installation:** Download and install Anaconda, then launch the Anaconda Prompt. - **Environment Setup:** Create (*conda create -n vpsc python=3.12*) and activate (*conda activate vpsc*) your virtual environment. - **Git Installation & Setup:** Install Git for Windows, open Git Bash, create a ``~/git/`` folder, and clone your repository. - **Package Installation:** Navigate to your repository folder and run *pip install -e .* - **IPython Testing:** Install IPython, launch it, and test your package’s example code. - **Spyder Configuration:** - Update your base Spyder using *conda update spyder*. - Install *spyder-kernels* in your *vpsc* environment. - Configure Spyder to use the *vpsc* interpreter (kernel) via **Tools → Preferences → Python interpreter**. - **VSCode Configuration:** - Install Visual Studio Code and the Python extension. - Set the Python interpreter to use the *vpsc* environment. - Open your project folder and configure the integrated terminal as needed. - *(Optional)* Setup WSL to run and test your code in a Linux environment directly from VSCode. Following these steps provides a fully configured Windows development environment that integrates Anaconda, Git, IPython, Spyder, and VSCode—using an updated base Spyder and a dedicated *vpsc* environment. Happy coding!