Problems with installing VPython on Jupyter Notebook - python

I am working on a project on Jupyter Notebook and I need to use VPython for some animations. I have Anaconda and the latest version of Python installed on my laptop. I have downloaded VPython from the command line using "pip install vpython" and I have checked that it is the latest version. (It might be useful to note that initially I had only Anaconda and Jupyter Notebook installed, and to download VPython I had to first download Python itself, then install pip, and finally install VPython). I have also installed the visual build tools and Node.js (but I don't have Jupyter Lab installed so I'm not sure if the latter is useful or not). I have followed all the instructions on https://vpython.org/presentation2018/install.html. Moreover, I have run the command "!pip install vpython" inside the Jupyter Notebook. However, when I try to run the following:
from vpython import *
sphere()
the Jupyter Notebook runs a bit, then stops and does not output anything. I also tried replacing "sphere()" with "box()", but this does not change anything. Same thing happens if I try to import only "sphere" from VPython and then run "sphere()".
I tried to search online and on this website for a solution, but I couldn't find anything. Any help would be very appreciated.
If it can be of any help, my web browser is Google Chrome and two friends of mine who are working on the same project are having the same issues with VPython.
EDIT: I tried running
%pip install vpython
in the Jupyter Notebook and I got some output saying that the requirement is already satisfied and the following comment: "Note: you may need to restart the kernel to use updated packages". I deleted the command "%pip install vpython", restarted the kernel and run the cell, but nothing was outputted.

There seem to be problems with the latest installer. A workaround is to install vpython 7.5.2. A new release is imminent.
I'll mention that for VPython questions it's better to post to the VPython forum, where there are many more VPython users who will see your question than if you post to stackoverflow:
https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users

VPython version 7.6.1 has just been released so try installing it to see if it fixes your problem.
pip install vpython --upgrade

Related

Unable to import numpy/pandas/matplotlib packages in VScode

I have used widely used packages(installed via pip) for a while in Jupyter notebook without any issues. I tried to do Python coding in VScode,but it somehow cannot load those packages.
I have tried changing python interpreter, but it did solve the issue. Does anyone know how to resolve this issue?
First make sure that you have the python interpreter installed on your computer. In your vscode UI you should see a terminal. You can install and upgrade pip through there if needed by using these commands:
pip install --upgrade pip
From here you should be able to import using pip commands.
Hi you can use terminal for installation.
otherwise you can anaconda iDE its very good tool and user friendly.

There are two hover message when my cursor over the python code

What I have tried:
Reboot the system. Done but nothing happens.
Uninstall the pylance and python extension. Done but nothing happens.
Install vscode insider and open the same jupyter notebook file. Done but the same issue still occurs.
Switch different conda virtual environments. Done but the same issue still occurs.
UPDATE
Add a GitHub link: https://github.com/microsoft/vscode-jupyter/issues/11938
Upgrading the jupyter extension to the pre-release version (2022.11.1003131031) solved the problem.
It may be an exception brought by the version update, resulting in repeated code prompts.
Rolling back the Python extension version to v2022.16.1 fixed the problem.
Open the python extension page and select Install Another Version...
select 2022.16.1 version
Restart vscode after installation is complete

Why can I not import a module (Batman) in Jupyter Notebook

I'm trying to import a module (batman, for model transits) in jupyter notebook, but its telling me file not found. However when I use the anaconda terminal it imports without issues
This is the error I get from Jupyter Notebook
I've tried reinstalling the package, and I've tried to find a kernel in which it works, but I'm not sure how to go about that
any help is appreciated
Try checking if the module installed properly by running this:
python -c 'import batman; batman.test()'
the batman module also seems to have some issues when installing on windows.
Read this github if you're on windows https://github.com/lkreidberg/batman/issues/26
I've faced the same issue when I use Jupyter in an Anaconda environment. Jupyter Notebook doesn't use the same kernel as Anaconda and I had to specify it manually.
What you can do is comparing the Python version on your Anaconda environment by running this command in your shell:
python --version
And in your Notebook :
import sys
print(sys.version)
Are the versions different ? If so, you must add your Anaconda kernel to your Notebook :
ipython kernel install --name "local-anaconda-env" --user
Then select it in your Notebook.
I was facing the same issue in VSC. What I did is that first I moved the folder(In your case batman) to where VSC had been installed on my laptop. Then I changed the default directory to where VSC was installed on my laptop by running the following code in VSC.
import os
os.chdir("The path where VSC is installed")
Also If you could try to do the code in a python file instead of jupyter notebook
In a cell within your notebook run the following:
%pip install batman-package
Based on here.
And the use of modern pip install magic to handle installing to correct enviornment from inside a notebook, see here.
For others, hitting here and not seeing what they want/expect.
Above is for batman:
Bad-Ass Transit Model cAlculatioN. Associated Github Repo is here, and Python Package Index page.
This is a poor name for a package as at least three developers have claimed this. Also see:
Anaconda install for Batman at conda-forgeBayesian Analysis Tool for Modelling and uncertAinty quaNtification
BATMAN: A Python deployment toolbelt -Batman 0.7.0 at the Python Package Index
Maybe those links will help you.

How to properly setup Spyder on macOS?

So I installed Spyder with anaconda navigator while following an online python course. However, the teacher's copy seems to feature code completion and documentation and mine does not. I've tried typing pip install Spyder into the terminal to install any dependencies and pip install rope_py3k because another StackOverflow answer suggested doing so. However, my Spyder app still does not have autocompletion. How do I fix this?

In python in jupyter notebooks, unable to import wikipedia API after installing with "pip3 install wikipedia"

While I was unable to import Wikipedia in jupyter notebook, in command prompt I am able to import Wikipedia. How to successfully import in Jupyter?
Run the following in your notebook and then try your import again.
%pip install Wikipedia
That is the current best way to use pip inside your Jupyter notebook environment, see here. That will help you on a per notebook level.
For fixing it so you don't need that %pip install <package> in your notebook, you need to sort out which python your Jupyter is using (running !which python in your running notebook would help) and make sure that you install your packages to that version or environment. For fixing that you may want to look around at already answered questions, such as here, here, here, and here. Those examples are just the tip of the iceberg, if you search around.

Categories

Resources