Plot Vectors with CalculusWithJulia Package is not Working in JupyterNotebook

Hi all,

I am using CalculusWithJulia, it works and showing the plot of vectors addition when I use the REPL. But when I use Jupyter Notebook, it does not work.

I install the sympy by pip install sympy but it is not recognized by Jupyter Notebook.

using CalculusWithJulia

using Plots
gr()       # better arrows than plotly()
quiver([0],[0], quiver=([1],[2]))

unzip(vs) = Tuple(eltype(first(vs))[xyz[j] for xyz in vs] for j in eachindex(first(vs)))

u = [1, 2]
v = [4, 2]
w = u + v
p = [0,0]
quiver(unzip([p])..., quiver=unzip([u]))
quiver!(unzip([u])..., quiver=unzip([v]))
quiver!(unzip([p])..., quiver=unzip([w]))

The error in Jupyter Notebook says:
ModuleNotFoundError(“No module named ‘sympy’”,)


I’m guessing that you have an old version of CalculusWithJulia being loaded, as it shouldn’t need SymPy to be installed now. But, for this error, if updating doesn’t work, try installing SymPy.

I check my version, it is the latest I think:

[a2e0e22d] CalculusWithJulia v0.0.1

I try to tweak to make it works. The creator of the package, great notes that you make on Calculus.

No, that’s the first, the latest should be v0.0.22. Maybe using Pkg; Pkg.update() will help sort this out.

I am going to share to others who want to use CalculusWithJulia in the future.

I type this in terminal (I use Linux+Python3+Julia 1.7.3)

pip3 install sympy
which python3

/usr/bin/python3

In Julia REPL:

    ENV["PYTHON"]="/usr/bin/python3"
    using Pkg
    Pkg.build("PyCall")

Then I am able to plot the vectors addition. I need this for Linear Algebra. Thanks for the suggestion, I have tried to update it but still stuck at this version, will try again later.

Those extra steps should be unnecessary, as installing SymPy should pull in a working sympy library through the magic of PyCall.jl and Conda.jl.

This is the failed upgrading of CalculusWithJulia:

Can you try ]st to see all the packages you have in your project? It might be the case that another package is holding back the upgrading of the package.

Alternatively, one could try ]up to update all the packages in your project so as to update the blocking package as well as CalculusWithJulia.jl (this might lead to other issues, so be careful).

1 Like

What kind of other issues?

I will try it later then. Thanks

I just remembered to mention two things:

  1. If you want to debug packages not upgrading, one could try ]add CalculusWithJulia@0.0.22 (in this case) and see the errors that had occurred.

  2. The issues is sometimes in a development environment, there are other packages that you rely on with breaking updates. It is likely in the case of CalculusWithJulia, this is not the case, but in general for development, upgrading all the packages might cause your existing codebase to fail of which there are usually 2 choices: editing your existing to code to be compatible with the upgrade version of other packages, or just give up and rely on the older version of packages.

Thanks @Syx_Pek for your guidance,
I think it is very complicated the error message is very long:

I feel like I’m giving this answer about once a week on here, recently I also gave it on SO so now I’m linking to that:

https://stackoverflow.com/questions/73054419/julia-unsatisfiable-requirements-detected-for-package-error-when-installing-mu/73068667#73068667

TL;DR: don’t install packages in the default environment, work with project specific environments instead.

If I were to work with Julia REPL then I can do:

] activate --temp
(then add the necessary packages)

But how about if I am to use Jupyter Notebook
which code should I put before I open Jupyter Notebook, here how I usually open Jupyter:

julia

julia> using IJulia
julia> notebook()

So we shouldn’t use JuliaDB then.

As I said in the SO answer:

In short, make a new folder for whatever analysis you’re working on and do ] activate . in that folder to start a new environment to which you only add the specific packages needed for that analysis.

IJulia can parse Pkg REPL mode syntax, alternatively you can do using Pkg and then use the functional API.

JuliaDB was the specific issue that the OP on SO faced, so might not have anytthing to do with your problem. In general though it’s probably correct to say that JuliaDB shouldn’t be used by most people at this point (unless and until a new maintainer for the package steps up).