Forum

Notifications
Clear all

Setting up python environment  

   RSS

0

Hi all,

I already have conda installed, along with various IDEs like pycharm and MS visual studio code.

As per instruction, I opened the Ex_LinearRegression_start.py file and tried to run part of the code (importing of packages). So first, I had the error message stating this:

PS C:\Users\User\Documents\PythonProjects\MicrosoftPython> & c:/Users/User/Documents/PythonProjects/MicrosoftPython/venv/Scripts/Activate.ps1
& : File C:\Users\User\Documents\PythonProjects\MicrosoftPython\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.

I googled around and it seems like I had to run some other commands in conda prompt to allow scripts to run. (can someone confirm that this is supposed to be the case?)

Next, I tried to run the script again after allowing scripts to run. I got the following:

PS C:\Users\User\Documents\PythonProjects\MicrosoftPython> & c:/Users/User/Documents/PythonProjects/MicrosoftPython/venv/Scripts/python.exe "c:/Users/User/Documents/PythonProjects/AISG Python/5 - Supervised Learning/Regression/learnai_regression2/learnai_regression2/Exercises/RegressionProject/Ex_LinearRegression_start.py"
No Python at 'C:\Users\User\AppData\Local\Programs\Python\Python37-32\python.exe'

I went to check the file path and indeed I think I have a different python version. It shouldve been Python38-32\python.exe.

Can someone tell me how I should make this change?

2 Answers
0

Hi all,

this is the full error message i got when trying to run in MS VC:

PS C:\Users\User\Documents\PythonProjects\MicrosoftPython> & c:/Users/User/Documents/PythonProjects/MicrosoftPython/venv/Scripts/Activate.ps1
& : File C:\Users\User\Documents\PythonProjects\MicrosoftPython\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ & c:/Users/User/Documents/PythonProjects/MicrosoftPython/venv/Scripts ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\User\Documents\PythonProjects\MicrosoftPython> & c:/Users/User/Documents/PythonProjects/MicrosoftPython/venv/Scripts/python.exe "c:/Users/User/Documents/PythonProjects/AISG Python/5 - Supervised Learning/Regression/learnai_regression2/learnai_regression2/Exercises/RegressionProject/Ex_LinearRegression_start.py"
No Python at 'C:\Users\User\AppData\Local\Programs\Python\Python37-32\python.exe'
0

In order to set up python environment in vscode, you will have to select the interpreter via the command palette (ctrl+shift+p)

https://code.visualstudio.com/docs/python/environments

 

For the error, you might want to consider looking at this solution on their github:

https://github.com/microsoft/vscode-python/issues/2559#issuecomment-507012853

 

Share:

Delete your account