Import Board Package on Julia and use Infinity

Hi Guys, am new to Julia and am developing a Tic Tac Toe AI board game and i happen to have issues with importing board.I know in python it’s
import board

how do i do this in Julia?

using Board

Or are you talking about importing a python package in julia?

using PyCall
board = pyimport("board")
1 Like

I have tried using Board
but I get the following error

julia> Pkg.add(“Board”)
Updating registry at C:\Users\NEW\.julia\registries\General
Updating git-repo
ERROR: The following package names could not be resolved:

  • Board (not found in project, manifest or registry)
    Please specify by known name=uuid.

It is


In python import load a file, but in Julia using read a package, not a file, and a package has a specific structure.

@dmolina am trying this but it doesn’t work, could kindly provide more info on how i should use it? thanks

It is not fully clear to me, what you are trying to do. So is board.jl some file you created on your computer? Or is it some repo on github? Or is it a python package?

The PyCall docs:

By default on Mac and Windows systems, Pkg.add("PyCall") or"PyCall") will use the Conda.jl package

Implying not used on Linux (is that outdated, and used there too?). At least on Linux, where you have Python 3 preinstalled, I could do (and I don’t find that package in Anaconda), and note the 3 in pip3, therefore may be important:

shell> pip3 install board

but then had to build PyCall correctly:

julia> ENV["PYTHON"] = "python3"  # will not be enough on Windows, see docs

julia> using Pkg;"PyCall")

exit Julia and start again:

julia> using PyCall

julia> board = pyimport("board")

julia> b[0, 0] = "X"  # works, but warning:
┌ Warning: `setindex!(o::PyObject, v, i1::Integer, i2::Integer)` is deprecated, use `set!(o, (i1 - 1, i2 - 1), v)` instead.
│   caller = top-level scope at REPL[12]:1
└ @ Core REPL[12]:1

You can e.g. do as in Python (for strings and this package, index from the end of the board):

julia> set!(b, (-1, 0), "X")

julia> get(b, (-1, 0))

Note, in general such negative indexing or starting from 0 in not done in Julia. I believe the deprecation above (can you disable the warning? I think it’s only in the REPL, not your working program) is there to allow the usual indexing as done in Julia, in a future PyCall version, for Python objects, shifting for you by one (and I guess loosing out on the negative, Julia uses “end” for that, or end-n).

1 Like