What's new

Help Portable Setup for VSCode + Python + Jupyter

Scavenger

⚠️ Inactive
Joined
Jun 3, 2015
Posts
19,470
Solutions
32
Reaction
8,863
Points
5,007
Hello sa mga coders dyan. Pa help naman baka alam nyo pano ma setup to.

Context:
Gusto ko sana gawin yung setup nato, para dala2x ko lang kahit saan ang mga ginagawa ko (practicing pa kasi so basta may time, nag e-explore)
Bali may PC ako sa bahay, naka install din mga yan albeit not portable mode, just the normal way.
Pero may work ako sa morning, which is most of the time naka tambay lang din dun sa office kaya ginagamit ko yung time to explore things such as programming.
Medyo sensitive yung pc ko dun, bawal installan kaya nais ko sana nasa external drive ko lang.

Challenge:
May mga TUT online kung pano gawing portable ang vscode, kung pano gawing portable ang python etc.
Kaso pag pinagsabay na sila... palaging errors, di ma locate ng vscode yung python ko which is portable na nakasave din sa external drive. lalong-lalo na si jupyter, nung nag run ako, need nya ng ipykernel packages which is na download naman.. pero dun pumunta sa "appdata/roaming" directory ng pc which is a NO NO.. buti nalang na locate ko agad at dinelete ko pero yun nga ayaw mag run if wala dun ang mga files.. Pano po kaya ma relocate yun sa external drive ko at pano e setup si vscode to point to that external drive when using the jupyter etc..

TIA.
 
Hello!

Here's a step-by-step guide on how to set up a portable development environment using VSCode, Python, and Jupyter on an external drive:

1. Download and install Visual Studio Code in portable mode. You can download the portable version of VSCode from the official website.

2. Download and install Python in portable mode. You can download the portable version of Python from the official website.

3. Set up your environment variables. Open your system's advanced settings and add the following to your system's environment variables:

- Add the path to your Python executable to the PATH variable.
- Add the path to your Python scripts to the PYTHONPATH variable.

4. Install the necessary Python packages. Open a command prompt and use pip to install the required Python packages:

pip install ipykernel jupyterlab

5. Launch VSCode and install the Python extension. Open VSCode and install the Python extension by going to the Extensions panel and searching for "Python".

6. Configure VSCode to use the portable Python interpreter. Open the command palette in VSCode by pressing Ctrl+Shift+P (Windows) or Command+Shift+P (Mac) and select "Python: Select Interpreter". Choose the Python interpreter installed in the external drive.

7. Set up Jupyter to use the portable Python interpreter. In VSCode, open the command palette and select "Python: Create Jupyter Notebook". This will create a new Jupyter notebook with the kernel set to the Python interpreter installed in the external drive.

8. Save your Jupyter notebooks to the external drive. When you save your Jupyter notebooks, make sure to save them to the external drive instead of the default path.

With these steps, you should be able to set up a portable development environment that you can take with you wherever you go. Let me know if you have any further questions!
 
  • possible problems to be encountered:
3. Set up your environment variables. Open your system's advanced settings and add the following to your system's environment variables:

  • Add the path to your Python executable to the PATH variable.
  • Add the path to your Python scripts to the PYTHONPATH variable.
For this point, parang need ko yata e change ang path variable to every PC I use. Tama po ba??.. How can I eliminate this part. Para sana no alteration to the PC.
6. Configure VSCode to use the portable Python interpreter. Open the command palette in VSCode by pressing Ctrl+Shift+P (Windows) or Command+Shift+P (Mac) and select "Python: Select Interpreter". Choose the Python interpreter installed in the external drive.
Ito rin na encounter ko to. Everytime ibang pc ginamit ko, hindi na nya ma locate yung python interpreter lalo na pag naiba na yung Drive letter ng external drive ko..
 
  • possible problems to be encountered:
For this point, parang need ko yata e change ang path variable to every PC I use. Tama po ba??.. How can I eliminate this part. Para sana no alteration to the PC.​
Yes, you will need to change the path variable on every PC you use to point to the location of your portable Python installation. One way to eliminate this step is to include a batch file with your portable setup that automatically sets the environment variables on the PC.

Here are the steps to create a batch file:

1. Open Notepad or any text editor.
2. Type the following commands:

set PATH=%CD%\python\;%CD%\python\Scripts\;%PATH% set PYTHONPATH=%CD%\python\;%PYTHONPATH%

3. Save the file with a .bat extension. For example, you can name the file setenv.bat.

When you connect your external drive to a PC, simply run the setenv.bat batch file to set the environment variables.

Alternatively, you can create a Windows PowerShell script that sets the environment variables:

1. Open Notepad or any text editor.
2. Type the following commands:

$env:PATH = "$($pwd)\python\;$($pwd)\python\Scripts\;$env:PATH" $env:PYTHONPATH = "$($pwd)\python\;$env:PYTHONPATH"

3. Save the file with a .ps1 extension. For example, you can name the file setenv.ps1.

When you connect your external drive to a PC, simply run the setenv.ps1 file using Windows PowerShell to set the environment variables.

Ito rin na encounter ko to. Everytime ibang pc ginamit ko, hindi na nya ma locate yung python interpreter lalo na pag naiba na yung Drive letter ng external drive ko..
You can try the following steps to make sure that VSCode can find the Python interpreter on any PC you use:

1. Open VSCode and go to the "Python: Select Interpreter" command by pressing Ctrl+Shift+P (Windows) or Command+Shift+P (Mac).
2. Select the Python interpreter that is installed on your external drive.
3. Click the "Copy" button next to the interpreter path. This will copy the path to the clipboard.
4. Open the Command Prompt or PowerShell on the PC you want to use and type the following command:

setx PATH "%PATH%;<path_to_python_interpreter>"

Replace <path_to_python_interpreter> with the path to the Python interpreter that you copied to the clipboard.

This command will add the path to the Python interpreter to the PATH environment variable on the PC.

5. Restart VSCode and try running a Python script to see if it works.

By adding the path to the Python interpreter to the PATH environment variable, VSCode should be able to find the interpreter even if the drive letter of your external drive changes.
 
Back
Top