I installed a new python 64 bit in my program files folder. I changed my jupyter kernel file in AppData/Roaming/Jupyter/kernels/kernel.json to take this new python as the python.
the kernel. JSON is
{
"argv": [
"C:/Program Files/Python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "python 3.7 64 bit",
"language": "python"
}
The error when I open a new notebook is PermissionError: [WinError 5] Access is denied
What should I change to solve it?
your operating system is not allowing to edit your file. Try open your notebook in administrator mode.
Right click on file
Open as administrator
make changes.
try this I hope your problem will be solved.
Related
I am trying to debug an azure function app in VSCode using Python in a Windows10 environment. Whenever I launch the debugger it hangs for a long period of time and then opens a message box that says
ECONNREFUSED 127.0.0.1:9091
There are a bunch of posts about this but none seem helpful/can solve the problem. Here is what I've tried:
uninstalling and re-installing different versions of
azure-function-core-tools using windows installer, npm and chocolatey
uninstalling and re-installing Azure Functions extension in VS Code
changing the extension bundle
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.3.0, 4.0.0)"
}
modifying local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "python"
}
}
deleting C:\Users\admin.azure-functions-core-tools\Functions\ExtensionBundles
creating a function app from command line using "func init" and lauching debugger by running "func host start" in active venv
I am using Python38 and really have no idea what else to try. Any suggestions are welcome.
Thanks!
Cannot launch debugger for azure function app in VScode-
ECONNREFUSED 127.0.0.1:9091
This type of generic error may occur for a variety of reasons.
Need to check and modify:
First and foremost, check whether the versions of Azure functions core tools and Pip are upgraded to the current version:
To upgrade pip:
python -m pip install --upgrade pip
To install and upgrade azure-functions:
pip install azure-functions
Go to the below path,
view -> Command palette -> User Settings
Python functions, task runFunctionsHost windows command only work with powershell:
Set the integrated > default profile: Windows to PowerShell as PowerShell runtime host is functional with Python functions. It was previously set to "null".
The debug configuration is specified in your tasks.json and launch.json files in the .vscode folder.
As stated here , the default listening port in launch.json is set to 9091. Here, I updated it to "port: 7071" which is open for traffic on my function project, launched the files, and then executed the "Attach to Python Functions" debug task once again.
Under .VScode folder -> launch.json file, this configuration changes works for me.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "python_modules./.bin/func",
"console": "integratedTerminal"
},
{
"name": "Attach to Python Functions",
"type": "python",
"request": "attach",
"port": 7071,
"preLaunchTask": "func: host start"
}
]
}
Added multiple debug points, debugged and triggered successfully as shown below:
Also Check here for more approaches given by #Hari Krishna
found the solution at:
https://github.com/Azure/azure-functions-core-tools/issues/3160#issuecomment-1266273749
I ran command func start in verbose mode
func start --verbose
from there it was clear that the process timed out when trying to download a new extension bundle. Most likely due to slow internet. I manually installed the new extension bundle:
https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/3.15.0/Microsoft.Azure.Functions.ExtensionBundle.3.15.0_any-any.zip
(the full path should be in the --verbose output) and extracted to
C:\Users[user name].azure-functions-core-tools\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle\3.15.0
It now works. Thanks everyone for input.
I tried installing jupyter notebook without using anaconda and ran into some issues, specifically the red 'Kernel Error' that kept showing up.
However through this ques I was somewhat able to identify the issue where the default pythonpath in the kernel.json file in C:\Users\Ashish\AppData\Roaming\jupyter\kernels\python3 was for anaconda, so I added my python path using where python.
On running jupyter notebook on cmd and opening a .ipynb file causes a popup to show : Could not find a kernel matching Python 3. Please select a kernel, which shows an empty drop down list.
My Updated kernel.json file:
{
"argv": [
"C:\Users\Ashish\AppData\Local\Programs\Python\Python38\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
Nvm, on running jupyter kernelspec list showed an error:
json.decoder.JSONDecodeError: Invalid \escape: line 3 column 6 (char 18)
Fixed it by using C:\\Users\\Ashish\\AppData\\Local\\Programs\\Python\\Python38\\python.exe in the kernel.json file
I want to run python .py file in Visual Studio Code using Windows bash console.
What I tried to do:
Change default shell in settings.json:
{
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}
Add task in tasks.json to run python command with file name as an argument:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "python",
"isShellCommand": true,
"showOutput": "always",
"tasks": [
{
"taskName": "Run python in bash",
"suppressTaskName": true,
"args": ["${file}"]
}
]
}
There are a few problems to solve here:
Tasks are not being run in bash as I wanted
To access C drive I need to replace C:\ with /mnt/c in file path
Can you share with my solutions to those problems?
I don't have Windows 10 with bash but I'd imagine the problem is that you're not actually trying to run Python. You're trying to run bash (and then run python). Try setting the command to bash with params ["python", "$file"].
In earlier versions of IPython it was possible to load a specific profile by
ipython notebook --profile=my_profile
so that I can include things like autoreload in my_profile.
Since using IPython 4.0.1 (Jupyter actually) I'm getting the
[W 09:21:32.868 NotebookApp] Unrecognized alias: '--profile=my_profile', it will probably have no effect.
warning, and the profile is not loaded. Have you come across a workaround?
In Jupyter create a kernel for each profile.
Find the kernels directory under the jupyter configuration directory {jupyter configuration}/kernels (on my Mac this is $HOME/Library/Jupyter/kernels):
$ mkdir profile-x-kernel
$ cat << EOF > profile-x-kernel/kernel.json
{
"display_name": "Profile X (Python 3)",
"language": "python3",
"env": { },
"argv": [ "python3", "-m", "ipykernel", "--profile", "profile_x", "-f", "{connection_file}" ]
}
EOF
Then you can select the kernel from the kernel menu in Jupyter, without having to restart the whole notebook server.
I am able to call my python from nodejs on AWS Lambda using the below function. However, because I need specific python libraries, I created a virutalenv in the env directory. I zipped everything up and pushed to Lambda. But when I try and call python from the virtual directory I get a Permission Denied error.
I attempted to modify the chmod permissions on Lambda before calling python but got Operation Not Permitted. How can I get this to run?
console.log('Loading event');
var exec = require('child_process').exec;
exports.handler = function(event, context) {
exec('env/bin/python district.py \'' + JSON.stringify(event) + '\'', function(error, stdout) {
var obj = stdout.toString();
context.done(error, obj);
});
};
Here's the error:
{
"errorMessage": "Command failed: /bin/sh: env/bin/python: Permission denied\n",
"errorType": "Error",
"stackTrace": [
"",
"ChildProcess.exithandler (child_process.js:658:15)",
"ChildProcess.emit (events.js:98:17)",
"maybeClose (child_process.js:766:16)",
"Process.ChildProcess._handle.onexit (child_process.js:833:5)"
]
}
The error most likely signals that python.exe does not have the executable bit set. Note, however, that even if you set the x bit, it won't work: .exe files are Windows executables, and they won't work.
Note, this virtual env was created in windows. I also attempted from Linux in the i.e. env/bin/python district.py with no help.
env/bin/python is the correct command. If you still get the Permission Denied error, the it means that the file python is missing the executable bit.
In the AWS Lamba runtime environment, you are not allowed to change permissions of files, nor to change user, therefore you must set the executable bit (or any other permission bit you need) when creating the .zip archive.
To sum up:
On Linux machines, use Linux executables.
Set the executable bit of the executables before creating archive.
Try this out:
exec('python district.py "'+ JSON.stringify(event) +'"', function(error, stdout) {
console.log('Python returned: ' + stdout + '.');
context.done(error, stdout);
});
Amazon has a tutorial on using Python in Lambda here