New to Julia - Need some basic help

2,067 views
Skip to first unread message

Pigskin Ablanket

unread,
Aug 19, 2016, 6:09:05 AM8/19/16
to julia-users
Ok, I am trying to familiarize myself with a study published using Julia.  I have Julia up and running, but cant seep to get the actual code open.

Here is what I done so far:
julia> Pkg.add("JuMP")
julia> Pkg.add("DataFrames")
julia> Pkg.add("GLPKMathProgInterface")
I believe I successfully added the requisite programs.  all good.  Now I downloaded the code via CSV.  
It contains the Code in a .jl file, license file, readme file and a couple excel CSV files needed.
I tried top open the file using Julia> Open("Filename.jl") and got the following error:
No such file or directory in open at iostream.jl:90  in open at iostream.jl:99
My sense is that I dont have the file in the right directory, but this is where I get over my skis.
Is that the issue?  How do I make Julia find the file?  Sorry or such basic questions !!!!

Michele Zaffalon

unread,
Aug 19, 2016, 6:17:38 AM8/19/16
to julia...@googlegroups.com
What code did you download?

Ayush Pandey

unread,
Aug 19, 2016, 6:26:20 AM8/19/16
to Julia Users
Hello there,
I think you need to change to the directory where your file is present.

You can try to use command line within julia like:
julia > ;pwd                 #Check your present working directory
julia> ;cd /path_to_the_directory_where_your_file_is_present

OR 
try to give the absolute path of the directory (Assume your file is present in home directory on linux)

julia>open("/home/Filename.jl")

I hope it helps :)


Yours Sincerely,
Ayush Pandey        
ayush-iitkgp.github.io/

Simon Danisch

unread,
Aug 19, 2016, 6:53:53 AM8/19/16
to julia-users
Also, are you looking for include("Filename.jl") ?

Jeffrey Sarnoff

unread,
Aug 19, 2016, 8:40:31 AM8/19/16
to julia-users
Where is the code that you downloaded, what is the http:// of that? 

Pigskin Ablanket

unread,
Aug 19, 2016, 8:41:51 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
Ok - This makes sense to me.......but:

When I proceeded with julia>;pwd this is the response I got: Error: could not spawn `pwd`: no such file or directory (ENOENT) in _jl_spawn at process.jl:262

No idea what that means :(

Once again - feel like my questions are probably introductory, and I appreciate your time.

The actual name of the code I am trying to open is titled "Code_for_Github.jl"

Jeffrey Sarnoff

unread,
Aug 19, 2016, 8:43:29 AM8/19/16
to julia-users
I mean what is the url of the file[s] / the link from which you downloaded the code?

Pigskin Ablanket

unread,
Aug 19, 2016, 8:47:07 AM8/19/16
to julia-users
The link to the folder is: https://github.com/dscotthunter/Fantasy-Hockey-IP-Code  which has a zip file of the code and sample information

I was unable to det the file via: $ git clone https://github.com/dscotthunter/Fantasy-Hockey-IP-Code  so I downloaded the CSV file and extracted it.   I feel like I need to extract those files to a specific location, but cnat figure out where.....as I dont know what directory I have Julia working in (if that makes sense).



On Friday, August 19, 2016 at 8:40:31 AM UTC-4, Jeffrey Sarnoff wrote:

Jeffrey Sarnoff

unread,
Aug 19, 2016, 9:33:30 AM8/19/16
to julia-users
what do you see when at the julia> prompt you type (notice the backtics are not single quotes)
run(`pwd`)

Jeffrey Sarnoff

unread,
Aug 19, 2016, 9:35:12 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
what do you see with this (in Julia, note the backtics are not single quotes)
julia> run(`pwd`)

Pigskin Ablanket

unread,
Aug 19, 2016, 10:02:36 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
I get the same error:  
Julia>run(`pwd`)   what I tried to execute
ERROR: could not spawn `pwd`: no such file or directory (ENOENT) in _jl_spawn at process.jl:262

I am attaching a screen shot
ERROR - Julia.jpg

Jeffrey Sarnoff

unread,
Aug 19, 2016, 10:04:20 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
Please show me
julia> versioninfo()

Jeffrey Sarnoff

unread,
Aug 19, 2016, 10:07:21 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
What is the machine/OS you are using? Is it yours, a school's? 

Pigskin Ablanket

unread,
Aug 19, 2016, 10:16:22 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
Julia Version 0.4.6
Commit 2e358ce (2016-06-19 17:16 UTC)
Platform Info:
-- System: windows (x86_64-w64-mingw32)
-- CPU: Intel(R) Core (TM) i5-4310U CPU @ 2.00GHz
-- Word_Size: 64
-- BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
-- LAPACK: libopenblas64_
-- LIBM: libopenlibm
-- LLUM: libLLUM-3.3

Its work computer

Jeffrey Sarnoff

unread,
Aug 19, 2016, 10:48:41 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
on a Win7 system running Julia (v0.5rc2, but that should not matter).


julia> run(`cmd`)
Microsoft Windows ...

# this is the directory from which Julia is being run (if you see it_
C
:\Users\Jeff\AppData\Local\Julia-0.5.0-rc2>ls
LICENSE
.md  Uninstall.exe  bin  etc  include  julia.lnk  lib  libexec  share

# type exit() to get back to julia
C
:\Users\Jeff\AppData\Local\Julia-0.5.0-rc2>exit()


julia
>



if you cannot do 
run(`cmd`)
on a windows machine then the System Administrator needs to reinstall or otherwise fix it
also, just for fun.. run Pkg.update()

Pigskin Ablanket

unread,
Aug 19, 2016, 10:56:39 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
Ok, so it showed me the following:
C:\Users\Name\AppData\Local\Julia-0.4.6

Should I still run the update?

Jeffrey Sarnoff

unread,
Aug 19, 2016, 11:15:05 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
you probably should run it -- and not expect that to make any difference with your difficulty (which is either a matter of installation or, more likely, the permissions associated with your windows account [and you may need to work that out with work])

Pigskin Ablanket

unread,
Aug 19, 2016, 11:22:18 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
Running update.  Work wont be an issue- he will help, but he is also new to Julia so a little bit of trial by fire :)   I appreciate the help very much.  If this doesnt work - I will uninstall and then re-install and hopefully get this file to run at least once :)

Steven G. Johnson

unread,
Aug 19, 2016, 11:22:46 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in


On Friday, August 19, 2016 at 8:41:51 AM UTC-4, Pigskin Ablanket wrote:
Ok - This makes sense to me.......but:

When I proceeded with julia>;pwd this is the response I got: Error: could not spawn `pwd`: no such file or directory (ENOENT) in _jl_spawn at process.jl:262

Typing

; command

in the julia REPL (the julia> prompt) executes a command in the operating system's shell.   pwd is a command in the unix shell, so it won't work in Windows where the shell is the DOS shell (cmd.exe), which is the reason for your error.   Similarly for run(`pwd`).

If you want to write portable code, you should generally avoid the OS shell entirely (and in any case the semicolon trick only works in the REPL).  For example, you can get the current directory via the pwd() function in Julia.

Pigskin Ablanket

unread,
Aug 19, 2016, 11:29:53 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
Given the above directory - where do I need to put the code file (code_for_Github.jl) so that Julia will see it to open it?  Is the command simply Open("code_for_Github.jl")

Pigskin Ablanket

unread,
Aug 19, 2016, 11:35:08 AM8/19/16
to julia-users, ayush....@iitkgp.ac.in
I get a different error now.  Open("code_for_github.jl") returns ERROR: UndefVarError: Open not defined

Jeffrey Sarnoff

unread,
Aug 19, 2016, 11:36:31 AM8/19/16
to julia...@googlegroups.com
hold on -- its not open()

Jeffrey Sarnoff

unread,
Aug 19, 2016, 11:56:14 AM8/19/16
to julia-users
ok -- I got it started.

Because that github is not set up as a Julia package, you can put the files (the .jl and the .csv files) anyplace that is handy, and you need to edit the .jl file so that path_skaters, path_goalies, and path_to_output all include the full directory path [e.g. (replace the dots) path_skaters = "C:/Users/../example_skaters.csv"].  
then to run it, 
julia> include("C:/Users/../codefile.jl") # replace the dots and 'codefile'

Pigskin Ablanket

unread,
Aug 19, 2016, 12:47:24 PM8/19/16
to julia-users
Thank you so much -- Ok - getting close.  I made the changes as discussed:

"C:/Users/JHerron/My_Documents/My_Documents/Personal/DFS/NHL/Julia/example_goalies.csv" etc (goalies, skaters and output).

I ran as follows:
Julia> include("C:/Users/JHerron/My_Documents/My_Documents/Personal/DFS/NHL/Julia/code_for_Github.jl")

and got back....  ERROR: could not open file C:/Users/JHerron/My_Documents/My_Documents/Personal/DFS/NHL/Julia/code_for_Github.jl in include at boot.jl:261 in include_from_node1 at loading.jl:320

Jeffrey Sarnoff

unread,
Aug 19, 2016, 12:53:46 PM8/19/16
to julia...@googlegroups.com
change all the forward slashes to back slashes (or double all the forward slashes) in the filepaths in code_for_Github.jl
and when use include e.g.
C:\Users\JHerron\My_Documents\My_Documents/Personal\DFS/NHL\Julia/code_for_Github.jl

Pigskin Ablanket

unread,
Aug 19, 2016, 12:57:38 PM8/19/16
to julia-users
Sorry - slow learner group here.  Change ALL (in the skaters path, output, and include code?)

Pigskin Ablanket

unread,
Aug 19, 2016, 1:47:59 PM8/19/16
to julia-users
Sorry if Im not following - I tried:

Include("C:\Users\JHerron\My_Documents\My_Documents/Personal\DFS/NHL\Julia/code_for_Github.jl") aas shown below and got ERROR: syntax: invalid escape sequence

include("C://Users//JHerron//My_Documents//My_Documents//Personal//DFS//NHL//Julia//Code_for_Github.jl") and got ERROR: could not open file C:/Users/JHerron/My_Documents/My_Documents/Personal/DFS/NHL/Julia/code_for_Github.jl in include at boot.jl:261 in include_from_node1 at loading.jl:320


On Friday, August 19, 2016 at 12:53:46 PM UTC-4, Jeffrey Sarnoff wrote:

Steven G. Johnson

unread,
Aug 19, 2016, 1:58:30 PM8/19/16
to julia-users


On Friday, August 19, 2016 at 1:47:59 PM UTC-4, Pigskin Ablanket wrote:
Sorry if Im not following - I tried:

Include("C:\Users\JHerron\My_Documents\My_Documents/Personal\DFS/NHL\Julia/code_for_Github.jl") aas shown below and got ERROR: syntax: invalid escape sequence

Backslashes have to be escsped in strings, like in many computer languages: change \ to \\ in the string.

However, usually it is better to just run Julia from within the path that you want rather than having to type absolute paths all of the time in the REPL.

(In the long run, you usually do large-scale code development in a module in the standard module search path, so you can just type "using Foo".)

(If you call include("foo.jl") from another file bar.jl, the path of foo.jl is automatically relative to the path of bar.jl, so again you neither need nor want absolute paths.)

For interactive code development where I need more than a few lines of code, I usually use a Jupyter notebook (google "IJulia").

Pigskin Ablanket

unread,
Aug 19, 2016, 3:10:39 PM8/19/16
to julia-users
Sorry - Im not a programmer, just want to use the tool to do some comparative work and potential modification for other uses.  Your comments are probably helpful...I just dont understand them.  I agree that I want something shorter so I dont have to type as much - but I still cant quite get it to execute yet.

Pigskin Ablanket

unread,
Aug 19, 2016, 3:17:46 PM8/19/16
to julia-users
I tried Include("C:Users\\JHerron\\My_Documents\\My_Documents/Personal\\DFS/NHL\\Julia/code_for_Github.jl")
(I hope that was what you meant to do).

I got: ERROR: UndefVarError: Include not defined


On Friday, August 19, 2016 at 1:58:30 PM UTC-4, Steven G. Johnson wrote:

Jeffrey Sarnoff

unread,
Aug 19, 2016, 4:49:16 PM8/19/16
to julia...@googlegroups.com
the "i" in include should be lower case

Pigskin Ablanket

unread,
Aug 19, 2016, 5:12:41 PM8/19/16
to julia-users
Sadly, I get the following response from include("C:\\Users\\JHerron\\My_Documents\\My_Documents/Personal\\DFS/NHL\\Julia/code_for_Github.jl")

ERROR: could not copen file C:\Users\JHerron\My_Documents\My_Documents\Personal\DFS\NHL\Julia\code_for_github.jl
in include at boot.jl:261
in include_from_node1 at loading.jl:320

Jeffrey Sarnoff

unread,
Aug 19, 2016, 6:01:50 PM8/19/16
to julia-users
two things,
you wrote:
 include("C:\\Users\\JHerron\\My_Documents\\My_Documents/Personal\\DFS/NHL\\Julia/code_for_Github.jl")
and I wonder, do you mean                               !                        !
 include("C:\\Users\\JHerron\\My_Documents\\My_Documents_Personal\\DFS\\NHL\\Julia\\code_for_Github.jl")
or
 include("C:\\Users\\JHerron\\My_Documents\\My_Documents_Personal\\DFS_NHL\\Julia\\code_for_Github.jl")

when you go to the directory where you see the file: code_for_Github.jl and you put the mouse on that file and right-click to see the popup menu and select the last thing "properties" there is something that says Location,if does it not exactly match:
C:/Users/JHerron/My_Documents/My_Documents/Personal/DFS/NHL/Julia
then you have miscopied it, if it looks like this 
C:/Users/JHerron/My_Documents/My_Documents_Personal/DFS_NHL/Julia
then you should be using (and fix the paths in the code_for_Github.jl file, too)
 include("C:\\Users\\JHerron\\My_Documents\\My_Documents_Personal\\DFS_NHL\\Julia\\code_for_Github.jl")

---

Pigskin Ablanket

unread,
Aug 19, 2016, 6:19:33 PM8/19/16
to julia-users
Thanks for providing me so much help today - much appreciated.

I copied the properties right here for folder Julia  which is where the code file is located:
C:\Users\JHerron\Documents\Documents\Personal\DFS\NHL

Interesting that it didnt bring it over as My_Documents.

Based on this, I would believe the command needs to be:
include("C:\\Users\\JHerron\\Documents\\Documents\\Personal\\DFS\\NHL\\Julia\\code_for_Github.jl")

Look correct?

I made the changes to the paths in the file as well....
"C:\\Users\\JHerron\\Documents\\Documents\\Personal\\DFS\\NHL\\Julia\\example_skaters.csv"

Jeffrey Sarnoff

unread,
Aug 19, 2016, 6:26:34 PM8/19/16
to julia-users
Look correct?
I will answer that after you try running it.

Pigskin Ablanket

unread,
Aug 19, 2016, 6:29:19 PM8/19/16
to julia-users
Well........Significant progress!!!! 3 Blue lines of Pre-compiling things before an Error:

Error: LoadError: syntax: "\" is not a unary operator
in include at boot.jl:261
in include_from_node1 at loading.jl:320
while loading C:\Users\JHerron\Documents\Documents\Personal\DFS\NHL\Julia\code_for_github.jl. in expression starting on line 38.

Picture of error posted
Julia3.jpg

Pigskin Ablanket

unread,
Aug 19, 2016, 7:01:54 PM8/19/16
to julia-users
IT Works!!!!!!!!   Thank you so much.  Found my error in the code.

I am curious if there is a way to shortcut the command as I would want to run this daily to test and it seems like a lot to type correctly.

Thanks for the time today

Jeffrey Sarnoff

unread,
Aug 19, 2016, 7:28:40 PM8/19/16
to julia-users
You are most welcome.

What do you want to change, if anything, from day to day, for example:  one or both input file names, the output file name, reuse some/all file names while changing the data inside?

Pigskin Ablanket

unread,
Aug 19, 2016, 8:04:58 PM8/19/16
to julia-users
I probably dont want to change the input file names more than once although I would be updating its data daily - and I think I know how to do that (change the name of the file itself as well as in the code).  The output file though - I might want to change more regularly,

Also - when I ran it - a few things were deprecated - does that just mean outdated?  Does updating with the new term change the file - or just the underlying solving?  Not sure if you can know that or not.

I was just looking for a way yo shortcut that long as heck include string I have now.  Cause I will run that daily and lord knows I mistyped it like 10 times.

Jeffrey Sarnoff

unread,
Aug 20, 2016, 12:13:40 PM8/20/16
to julia-users
There is a way -- after the weekend.

Pigskin Ablanket

unread,
Aug 22, 2016, 5:06:33 PM8/22/16
to julia-users
No problem.  If you get a chance - great
Message has been deleted

Jeffrey Sarnoff

unread,
Aug 23, 2016, 10:44:19 PM8/23/16
to julia-users
As Steven mentioned, starting the program from the directory where the files reside allows you to include the file using its filename without the full path.  If that is easy for you, it is probably best.  An alternative is to do it with code.  Let me know if you need that.

Pigskin Ablanket

unread,
Aug 24, 2016, 7:40:10 AM8/24/16
to julia-users
Looks like his comment got deleted.  Will try it today and follow up.  Thanks again for all the help

j verzani

unread,
Aug 24, 2016, 7:57:30 AM8/24/16
to julia-users
I haven't tested it on Windows, but the `Tk` package has `GetOpenFile()` that should allow for a dialog to navigate the file system. Something like `include(GetOpenFile())` should work.

Jeffrey Sarnoff

unread,
Aug 25, 2016, 1:05:20 AM8/25/16
to julia-users
on an empty area of the windows desktop, RIGHT-CLICK and select new > shortcut.
  where it says type the location of the item, type
    C:\\Users\\JHerron\\Documents\\Documents\\Personal\\DFS\\NHL\\Julia\\code_for_Github.jl
 then click on next

start Julia
julia> Pkg.update() # ignore everything, let it finish
julia> Pkg.add("Tk") # ignore everything, let it finish
julia> quit()

start Julia
julia> using Tk
julia> include(GetOpenFile())   
# go to the desktop, select the shortcut you made
# that code file should load and run

Jeffrey Sarnoff

unread,
Aug 25, 2016, 1:06:49 AM8/25/16
to julia-users
(before all that, rename the file to something simple like "everyday.jl")

Pigskin Ablanket

unread,
Sep 3, 2016, 11:33:16 AM9/3/16
to julia-users
So I tried all of this, but it looks like there was an error loading the TK package.  When I went to use Tk I got the following error message:

ERROR: LoadError: Cairo Package not properly installed. Please run Pkg.build("Cairo") in error at error jl:22 while loading.....  

Chris Rackauckas

unread,
Sep 3, 2016, 12:33:47 PM9/3/16
to julia-users
Did it build correctly after using Pkg.build("Cairo")?

Pigskin Ablanket

unread,
Sep 3, 2016, 1:49:36 PM9/3/16
to julia-users
Haha - good question.  Didnt know what Pkg.Build("Cairo") meant - so I havent run that yet.  Should I do that?

Chris Rackauckas

unread,
Sep 3, 2016, 1:53:01 PM9/3/16
to julia-users
Pkg.build("Package") will build the binaries for the package. You should run it since the package is saying it needs you to do it. Generally, packages which have a lot of binary dependencies (i.e. ones that link to C/C++ libraries) will require some form of building.

Pigskin Ablanket

unread,
Sep 3, 2016, 2:13:28 PM9/3/16
to julia-users
meh - errors running the Pkg.

Jeffrey Sarnoff

unread,
Sep 5, 2016, 5:47:10 PM9/5/16
to julia-users
Not easy to know what's happening there.
You might try:

julia> quit()
julia
> Pkg.rm("Cairo");Pkg.rm("Cairo");
julia
> Pkg.add("Cairo")
julia
> Pkg.build("Cairo")
julia
> quit()
julia
> using Cairo


if there are error messages, post 'em
otherwise do the same substituting "Tk" for "Cairo"
if there are error messages, post 'em

Jeffrey Sarnoff

unread,
Sep 5, 2016, 5:54:20 PM9/5/16
to julia-users
and before all that, start with `julia> Pkg.update()`
Reply all
Reply to author
Forward
0 new messages