# UndefVarError: linspace not defined

**URL:** <https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269>\
**Category:** New to Julia\
**Created:** [August 11, 2018, 9:05pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269 "2018-08-11T21:05:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![caishen29](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@caishen29](https://discourse.julialang.org/u/caishen29)\
**Post date:** [August 11, 2018, 9:05pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/1 "2018-08-11T21:05:11Z")

</div>

New to julia 1.0, I am running some examples and got the following errors, do you have any ideas how to solve this?  
Thanks.

‘’’  
julia\> linspace(0,2\*pi,10)  
ERROR: UndefVarError: linspace not defined  
Stacktrace:  
[1] top-level scope at none:0  
‘’’

---

<div class="post-metadata">

**Author:** ![migarstka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/migarstka/32/3828_2.png) [@migarstka](https://discourse.julialang.org/u/migarstka)\
**Post date:** [August 11, 2018, 9:13pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/2 "2018-08-11T21:13:42Z")

</div>

Linspace was deprecated. You should be able to use

```julia
range(0,stop=2*pi,length=10)

```

---

<div class="post-metadata">

**Author:** ![caishen29](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@caishen29](https://discourse.julialang.org/u/caishen29)\
**Post date:** [August 11, 2018, 9:53pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/3 "2018-08-11T21:53:16Z")

</div>

Worked!  
Thank you very much.  
BTW, where could I find the information about whether a specific function is deprecated or not?  
For “linspace”, I googled a lot before posting here, however I was failed to find any information about this.

---

<div class="post-metadata">

**Author:** ![migarstka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/migarstka/32/3828_2.png) [@migarstka](https://discourse.julialang.org/u/migarstka)\
**Post date:** [August 11, 2018, 9:55pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/4 "2018-08-11T21:55:24Z")

</div>

If you run the code with Julia v0.7 it will print a deprecation warning.

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [August 11, 2018, 11:22pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/5 "2018-08-11T23:22:04Z")

</div>

Even more readable with unicode 🙂

```julia
range(0, stop=2π, length=10)

```

---

<div class="post-metadata">

**Author:** ![pdenapo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdenapo/32/5686_2.png) [@pdenapo](https://discourse.julialang.org/u/pdenapo)\
**Post date:** [October 6, 2018, 4:09pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/6 "2018-10-06T16:09:45Z")

</div>

Then, if linspace is deprecated, please update the documentation at

[https://julialang.org/downloads/plotting.html](https://julialang.org/downloads/plotting.html)

It is very frustrating when you are a new user, you pick an example from a tutorial and it doesn’t work! I would suggest to try not to break old code.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 6, 2018, 4:56pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/7 "2018-10-06T16:56:47Z")

</div>

> [@pdenapo](#):
>
> Then, if linspace is deprecated, please update the documentation at
> 
> [https://julialang.org/downloads/plotting.html](https://julialang.org/downloads/plotting.html)

Good catch! The code is here [https://github.com/JuliaLang/www.julialang.org/blob/9f544a5476c74a74d7dfb1f15e939550e5dd851e/downloads/plotting.html](https://github.com/JuliaLang/www.julialang.org/blob/9f544a5476c74a74d7dfb1f15e939550e5dd851e/downloads/plotting.html), care to make a pull request?

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [October 6, 2018, 4:59pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/8 "2018-10-06T16:59:14Z")

</div>

Not OP, but [this](https://github.com/JuliaLang/www.julialang.org/pull/197) should do the trick. Looks like it just slipped through the cracks.

---

<div class="post-metadata">

**Author:** ![pdenapo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdenapo/32/5686_2.png) [@pdenapo](https://discourse.julialang.org/u/pdenapo)\
**Post date:** [October 6, 2018, 7:25pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/9 "2018-10-06T19:25:03Z")

</div>

### **[Seelengrab](https://github.com/Seelengrab) did it faster than myself!**

---

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [October 6, 2018, 8:06pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/10 "2018-10-06T20:06:12Z")

</div>

Just a question, is there any particular reason why stop became a named argument? It seems antisymmetric with the start argument.  
Be able to use as range(start, stop) would be nice.

---

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [October 6, 2018, 8:12pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/11 "2018-10-06T20:12:10Z")

</div>

[https://github.com/JuliaLang/julia/pull/28708](https://github.com/JuliaLang/julia/pull/28708)

In Julia v1.1 it will be the exactly the way you want. Until then, if you use Compat.jl with the current versions of Julia, you can use the new notation as soon as [https://github.com/JuliaLang/Compat.jl/pull/633](https://github.com/JuliaLang/Compat.jl/pull/633) is merged

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [October 6, 2018, 9:30pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/12 "2018-10-06T21:30:34Z")

</div>

> [@migarstka](#):
>
> If you run the code with Julia v0.7 it will print a deprecation warning

This is the correct answer.

But, being required to maintain a Julia v0.7 installation just to learn about a deprecated function is kind of a pain, even for people experienced with Julia. In practice, examples using `linspace` etc. will be around for some time, and will continue to cause confusion.

I’m just pointing it out. Not complaining about it. It has not bothered me enough to try to find a solution myself.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [October 6, 2018, 9:44pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/13 "2018-10-06T21:44:00Z")

</div>

> In practice, examples using linspace etc. will be around for some time, and will continue to cause confusion.

Gotta catch them all? [Here](http://steampiano.net/juliasearch/?s=linspace) are a few examples to start your collection off…

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [October 6, 2018, 9:53pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/14 "2018-10-06T21:53:49Z")

</div>

> [@jlapeyre](#):
>
> In practice, examples using `linspace` etc. will be around for some time, and will continue to cause confusion.

Maybe admit an error and get that function name back?

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [October 6, 2018, 10:04pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/15 "2018-10-06T22:04:14Z")

</div>

> [@joa-quim](#):
>
> Maybe admit an error and get that function name back?

All (or almost) of the decisions to make deprecations and replacements were discussed thoroughly over a long period and were made for good reasons.

---

<div class="post-metadata">

**Author:** ![anon32405968](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@anon32405968](https://discourse.julialang.org/u/anon32405968)\
**Post date:** [October 6, 2018, 11:20pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/16 "2018-10-06T23:20:59Z")

</div>

Sorry for digressing a bit from the OP, but I had this issue today as the convolution function from Julia 0.6 (`conv`) is not in Julia 1.0 and I could not find it in any of the release notes for 0.7/1.0.

In the end I went back to my 0.7 installation to try and get an informative warning message (it told me that `conv` had been moved to DSP.jl.

Is there somewhere with a more comprehensive list of deprecations than the release notes? Or if people find these should they submit a PR to change the 0.7 release note? Thanks

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [November 7, 2018, 7:50pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/17 "2018-11-07T19:50:49Z")

</div>

I’ve been having the same problem, not just with `linspace` but with `conv` as well.

As a new user this makes the language feel quite opaque, especially since the latest version of julia will throw a generic error message when trying to run simple example code from a few versions ago.

A better situation might be that when julia tries to call a known depreciated function, an error message is thrown detailing the version in which this function was depreciated, and the function that inherited it’s functionality along with the new syntax

If we can find a comprehensive list of depreciations this shouldn’t be so hard to implement, and It would work wonders for the accessibility of the language.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 7, 2018, 8:45pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/18 "2018-11-07T20:45:12Z")

</div>

> [@xtalax](#):
>
> If we can find a comprehensive list of depreciations this shouldn’t be so hard to implement, and It would work wonders for the accessibility of the language.

Yes, it’s called Julia 0.7.

---

<div class="post-metadata">

**Author:** ![Richard\_Thornton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/richard_thornton/32/6450_2.png) [@Richard\_Thornton](https://discourse.julialang.org/u/Richard_Thornton)\
**Post date:** [December 16, 2018, 5:07pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/19 "2018-12-16T17:07:31Z")

</div>

I understand that this syntax: x = linspace(0, 5) should be replaced by something like range(0,stop=5) ? How should the syntax be in this simple example?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 16, 2018, 5:12pm UTC](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269/20 "2018-12-16T17:12:23Z")

</div>

You would need to give a `length` or a `step`, eg

```julia
range(0; stop = 5, step = 1)

```

which can be written as `0:5` of course.

Note that when 1.1 comes out, you will be able to write

```julia
range(0, 5; step = 1)

```

[Next page](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269.md?page=2)
