How to use the Wolfram Language in a Jupyter Notebook (100th blog)

It is my 100th blog on EconMacro! I tried to provide some tips to access to knowledge all along these blogs. The idea is to try to make it as simple and accessible as possible. For this special occasion, let us explore two languages that I do not often use in my own research. Thus, I continue this series of blog on how to use different languages in a unique environment. We already saw that we can use Python from Mathematica. Now, I will show how to use the Wolfram Language in a Jupyter Notebook, in a few very simple steps.

How to change the working directory?

Before moving to the main objective of this blog let me show how to change the current directory in Python. Following this very pedagogical YouTube video made by Kevin Stratvert, I recommend using Visual Studio Code for the editor. Using an interactive window can be interesting to save a Jupyter notebook afterward. Execute line by line with Shift+Enter to understand each step.

# Importing the module
import os

# Getting the current working directory
cwd = os.getcwd()

# Printing the current working directory
print("The Current working directory is: {0}".format(cwd))

# Changing the current working directory
os.chdir('C:\\Users\\jamel\\Dropbox\\Documents\\Wolfram Mathematica\\Webinars\\WolframLanguageForPythonUsers\\WolframLanguageForPythonUsers\\')

# Print the current working directory
print("The Current working directory now is: {0}".format(os.getcwd()))

How to use the Wolfram Language in Jupyter?

First, you need to have a license for Mathematica. Then, install the Wolfram Client Library. The following steps are explained in the following file: WLwithPythonBlog.html. In the Jupyter notebook, you will be able to evaluate using Mathematica functions and ask questions to Wolfram Alpha.

You will start to learn how to build a unique notebook where you can use both languages, Python and Wolfram. The files are available on my GitHub.

Reference

2 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.