which app does anaconda used to run .py scripts - python

I was trying to run dronekit-SITL in windows so I downloaded the anaconda so that I can use py-2.7 separately, but when I try to run mavproxy.py script, it shows up a dialog box to choose an app to run the .py file, and when I click on any of the apps nothing happens.
this will show what my problem is actually

Jupyter Notebook
it will be installed along with anaconda

Related

Jupyter in VSCode

enter image description here
At first, jupyter notebook works fine. BUT, whenever I try to use the other ipynb file, jupyter notebook does not work and send this message. How should I deal with this?
Have you checked which python interpreter you are using in the Jupyter Notebook?
With the different names of the .ipynb file, it will take the different kernels, and it is stored in the database.
First of all, create a virtualenv. Open the terminal using Ctrl+Shift+`.
In the console, type python3 -m venv venv.
This will create a folder named venv in your working directory.
Now, in the bottom left corner, you will find the selected python interpreter. Click that and change it to venv.
(If windows raises permission error, In your vsCode settings, add the following lines.)
"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
Now delete all previous terminals and open a new terminal.
Install the required packages using pip and carry on.

Python Running .py File with my Python Anaconda Version

I think I am close to solving my issues but need a little help.
Computer: Mac
My situation: wrote a script in Jupyter Notebooks (.ipynb) and I wanted to run it from IDLE. So I downloaded the .ipynb as a .py file. When I open up the file it opens in Idle and when I go to run the file it says I do not have the module/packages installed.
At the top of the .py file it put #!/usr/bin/env python
When I run which python in my terminal I get /opt/anaconda3/bin/python.
So I am thinking IDLE is running the script through a different environment of python. How do I change it so IDLE will run the script through the python Anaconda also uses?
Thank you!
It is possible that you have more than one python in your OS. Just check the versions in prompt with --version. If you get different python version you need to delete one that you dont use. It is generally the other than anaconda one.

Open .ipynb in Anaconda Jupyter Notebook on double-click (macOS)

I've been trying to figure out how I can open a .ipynb file on double-click on a Mac, so the file opens with Anaconda and then automatically opens Jupyter Notebook with the file contents.
I have tried creating an application through Automator that opens with a jupyter_lab command, but the issue is that Jupyter lives in Anaconda, so this method is not working. See these articles for my steps: https://samedwardes.com/2020-01-31-open-ipynb-with-double-click/ and Open an ipython notebook via double-click on osx
I have also tried installing nbopen with the following:
python3 -m pip install nbopen
This works, and then I can run nbopen file.ipynb through the terminal, but I want to be able to bypass this step and do it while in file explorer, physically looking at the file instead.
I have ran the recommended command for osx to integrate it with file manager ./osx-install.sh but I just get zsh no such file or directory and can't really find any help with figuring out why this is pushing back an error.
Any suggestions?
I have this "convenience issue" as well, and didn't go for the nbopen route, but instead, I just made a batch script (I named it jupyter-notebook.bat) that calls certain conda functions, and pretty much initiates things like how double clicking works. In the script, I just have this:
call "C:\Users\XYZ\Anaconda3\Scripts\activate.bat"
call conda activate myEnvironment
call python C:\Users\XYZ\Anaconda3\Scripts\jupyter-notebook-script.py %1
Lastly you just need to configure that every .ipynb opens up using your jupyter-notebook.bat script.
For consistency, I placed the script in my Anaconda folder. And if you also have nb_conda_kernels installed in your base environment, you'd have access to the other environment you've created as well from there.

Why doesn't pynsist shortcut start python script?

I recently tried to build an installer of a python application built with PyQt5. Unfortunately, after getting the installer via .cfg file and installing it on another computer the script does not start by clicking the shortcut in the (Windows) start menu.
When trying to start the Python-script directly by double-clicking it in the according folder of the installation, Python keeps crashing since PyQt5 is not installed on the computer (although it can be found in the installation-folder). In case I manually install the package via pip install PyQt5 it works when clicking on the script, but not when using the shortcut in the menu.
I suppose this could have to do with the automatically generated file path of the shortcut, but I could not find a solution how to fix it when building the installer. I used script instead of entry_point for it - could it be that this produces my problem?
Thank you in advance!
Here is what my .cfg script looks like:
[Application]
name=sample_name
version=V0.1
publisher=sample_publisher
script=C:\path to Python script\launch_script.pyw
icon=sample_icon.ico
[Python]
version=3.6.3
[Include]
pypi_wheels=PyQt5==5.10
files=folder_with_additional_scripts
[Build]
directory=build\

double click to open an ipython notebook

Related posts: Open an ipython notebook via double-click on osx
How can I open Ipython notebook from double click? I always cd to the directory of the notebook, then type ipython notebook in the browser and then open it in the browser. This steps is very inconvenient.
In windows, I remembered that I can change the directory in the browser, but in linux there is no way to explore to other directory via browser, if I want to open a new book in another directory, I have to restart another kernel as above, which annoys me.
Is there any simple and verified way to do this?
You can use a project like nbopen that handle that and will open the browser on the right notebook + start an IPython server if one is not yet running.
pip install nbopen.
open Automator, create new Application
Drag'n drop Run Shell Script
Change Pass input to as arguments
Copy/paste this script:
variable="'$1'"
the_script='tell application "terminal" to do script "nbopen '
osascript -e "${the_script}${variable}\""
Save the new application to Applications directory as nb_open
Right click any ipynb file and select "Open with > Other" and select the nb_open in the Applications folder. Don't forget to check "Always Open With".
Select an ipynb file, get info (command + i) > Open With (select nb_open if not selected already) > Click Change All.... Done.
To "promote" Yogesh's helpful comment to a fully self-contained answer:
Windows 10
In a CMD or PowerShell window with administrative rights (e.g. launched quickly with Win+X, then A), run:
pip install nbopen
python -m nbopen.install_win
Profit!
Double-click on *.ipynb files now starts a new server or reuses an existing instance.
One way to open a Jupyter notebook directly by double-clicking on the file is to associate the .ipynb file extension with the jupyter-notebook command. Here's how to do it on a Windows system:
Right-click on the Jupyter notebook file that you want to open.
Select "Open with" and then choose "Choose another app".
Select "More apps" and then scroll down to the bottom and choose "Look for another app on this PC".
Navigate to the directory where the jupyter-notebook.exe file is located (usually in the Scripts subdirectory of your Python installation), and select it.
Check the box next to "Always use this app to open .ipynb files" and then click on "OK".
Now, when you double-click on an IPython notebook file, it should open directly in the Jupyter notebook.
On a Mac or Linux system, you can set the default application for .ipynb files by using the xdg-mime command. First, determine the full path to the jupyter-notebook executable:
which jupyter-notebook
This will return the path to the executable. Then, use the xdg-mime command to set the default application for .ipynb files:
xdg-mime default jupyter-notebook.desktop application/x-ipynb+json
Replace jupyter-notebook.desktop with the path to the jupyter-notebook executable that you determined earlier. Now, when you double-click on an IPython notebook file, it should open directly in the Jupyter notebook.

Categories

Resources