# Install Mosek.jl

**URL:** <https://discourse.julialang.org/t/install-mosek-jl/15083>\
**Category:** Optimization (Mathematical)\
**Created:** [September 17, 2018, 5:16pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083 "2018-09-17T17:16:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 17, 2018, 5:16pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/1 "2018-09-17T17:16:56Z")

</div>

I tried Pkg.add(“Mosek”) to add Mosek package but I got the following error " unknown package Mosek". I have no idea why I have received this error. Please let me know if you have been in the same situation.

---

<div class="post-metadata">

**Author:** ![jacob-roth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacob-roth/32/1862_2.png) [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Post date:** [September 17, 2018, 5:55pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/2 "2018-09-17T17:55:53Z")

</div>

Do you have a `Mosek` license? And if so, what directory is it stored in?

Adding `Mosek` requires a license to use it, but it seems your issue is before even building / compiling. Do you have more info?

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 17, 2018, 8:08pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/3 "2018-09-17T20:08:38Z")

</div>

I have already used Mosek in Yalmip and it works very well. However, I add Mosek.jl to use in julia but I received an error, after reinstalling Mosek I got the " unknown package Mosek" error.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 17, 2018, 8:15pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/4 "2018-09-17T20:15:01Z")

</div>

You may need to run `Pkg.update()` first.

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 17, 2018, 8:35pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/5 "2018-09-17T20:35:52Z")

</div>

I got the following error: Module SparseArrays not found in current path. Run ‘Pkg.add(“SparseArrays”)’ to install the SparseArrays pakage.

I tried to install the pakage while I got the following error:  
unknown Package SparseArrays

Please let me know if I have done something wrong in installation process?

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 17, 2018, 9:07pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/6 "2018-09-17T21:07:55Z")

</div>

What’s the output of `Pkg.status()` and `versioninfo()`?

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 17, 2018, 9:18pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/7 "2018-09-17T21:18:02Z")

</div>

Mosek 0.0.0 non-repo (unregistered)  
version 0.6.4

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 17, 2018, 9:52pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/8 "2018-09-17T21:52:14Z")

</div>

Try nuking your v0.6 package installation:

`rm(Pkg.dir(), recursive=true); Pkg.status(); Pkg.add("Mosek")`

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 17, 2018, 10:29pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/9 "2018-09-17T22:29:47Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/e/7/e7a849b319dedc95a9c84e2c05b1d03fdbd10a3a.png)

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 17, 2018, 10:59pm UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/10 "2018-09-17T22:59:36Z")

</div>

Please copy and paste terminal output (surrounded by triple backticks, ```) into Discourse rather than posting screenshots.

Can you navigate to [https://www.mosek.com/downloads/default\_dns.txt](https://www.mosek.com/downloads/default_dns.txt) in your browser?

If you know where Yalmip installed its Mosek binaries, you can also point Mosek.jl to that directory by setting the MOSEKBINDIR [environment variable](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html) to that location, then running `Pkg.build("Mosek")`.

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 18, 2018, 12:17am UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/11 "2018-09-18T00:17:23Z")

</div>

Sorry for the inconvenience! I did what you mentioned in your last post and it seems that Mosek works at this time. However, I got the following warning which I appreciate if you guide me to debug.

```julia
WARNING: requiring "SOS_envelopes" in module "Main" did not define a corresponding module.

```

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 18, 2018, 12:23am UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/12 "2018-09-18T00:23:38Z")

</div>

What command did you run to produce that output? In general, it’s good to provide as much context as you can when you ask questions so that readers can more easily duplicate the conditions that caused the problem (i.e. a [minimum working example](https://stackoverflow.com/help/mcve)).

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 18, 2018, 12:38am UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/13 "2018-09-18T00:38:15Z")

</div>

I used “using SOS\_envelopes” to run the code. Following is the SOS\_envelopes code that I have written to compute the best set of (a, b, and c).

```julia

using MultivariatePolynomials

using JuMP

using PolyJuMP

using SumOfSquares

using DynamicPolynomials

using Mosek

using SemialgebraicSets

@polyvar x

m = SOSModel(solver = MosekSolver())

@variable m a

@variable m b

@variable m c

epsilon = 0.001; x_min = -pi/2; x_max = pi/2;

P= a*x^2 + b*x + c - 1 + x^2/factorial(2) - x^4/factorial(4) + x^6/factorial(6) - x^8/factorial(8) + x^10/factorial(10) - epsilon;

S = @set x >= -pi/2 && x <= pi/2

x_max=pi/2;

x_min=-pi/2;

@objective m Min (1/3*a*x_max^3 + 1/2*b*x_max^2 + c*x_max+sin(x_max) - 1/3*a*x_min^3 + 1/2*b*x_min^2 + c*x_min+sin(x_min));

@constraint( m, P >= 0, domain = S)

```

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [September 18, 2018, 1:08am UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/14 "2018-09-18T01:08:20Z")

</div>

> [@Rasoul](#):
>
> using MultivariatePolynomials using JuMP using PolyJuMP using SumOfSquares using DynamicPolynomials using Mosek using SemialgebraicSets

If you want to run the contents of some file `SOS_envelopes.jl`, use `include("/path/to/SOS_envelopes.jl")`.

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [September 18, 2018, 1:57am UTC](https://discourse.julialang.org/t/install-mosek-jl/15083/15 "2018-09-18T01:57:08Z")

</div>

Thank you so much!
