Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to import third-party packages on Windows? #243

Open
lekeeith opened this issue Jan 26, 2022 · 1 comment
Open

[Question] How to import third-party packages on Windows? #243

lekeeith opened this issue Jan 26, 2022 · 1 comment

Comments

@lekeeith
Copy link

error writing file "C:\Users\smile\go\src\github.com\gopherdata\gophernotes\imports/thirdparty/gonum_org_v1_gonum_mat.go": open C:\Users\smile\go\src\github.com\gopherdata\gophernotes\imports/thirdparty/gonum_org_v1_gonum_mat.go: The system cannot find the path specified.

it is visiable to find the error is come from path, but i do not konw how to solve it.
image

@cosmos72
Copy link
Member

cosmos72 commented Feb 6, 2022

The procedure to import third-party packages on Windows is somewhat tedious, and requires compiling gophernotes twice.

Here it is, in its full length:

  1. manually download gophernotes inside GOPATH, compile and install it.
    The commands to enter at Windows command prompt (cmd) are:
set GOPATH=%USERPROFILE%\go
mkdir "%GOPATH%\src\github.com\gopherdata"
cd "%GOPATH%\src\github.com\gopherdata"
git clone https://github.com/gopherdata/gophernotes
cd gophernotes
go install .

You need to use these exact paths, because that's what gophernotes expects at step 4 below.

  1. configure jupyter notebook to find gophernotes as described at https://github.com/gopherdata/gophernotes/#windows
    i.e. execute the commands
mkdir "%APPDATA%\jupyter\kernels\gophernotes"
xcopy "%GOPATH%\src\github.com\gopherdata\gophernotes\kernel" "%APPDATA%\jupyter\kernels\gophernotes" /s

then edit the file %APPDATA%\jupyter\kernels\gophernotes\kernel.json replacing the string "gophernotes"
with the full path of gophernotes executable, surrounded by double quotes, as for example
"C:\Users\PUT_YOUR_USERNAME_HERE\go\bin\gophernotes"

  1. Start jupyter notebook (I am assuming it's already installed), typically by executing the command
jupyter notebook

and create a new Go notebook with New > Go

  1. At gophernotes prompt, import all the third-party packages you need. For example:
import (
  "gonum.org/v1/gonum/mat"
  "gonum.org/v1/gonum/floats"
)

for each import, you will get a message saying that a file has been created inside
C:\Users\PUT_YOUR_USERNAME_HERE\go\src\github.com\gopherdata\gophernotes
and that you need to recompile gophernotes.

Don't quit jupyter notebook yet: first, enter all the import statements you need.

Only after you have typed all the import statements (and got a similar message for each, saying that you need to recompile gophernotes), quit jupiter notebook.

  1. Recompile gophernotes with the commands:
set GOPATH=%USERPROFILE%\go
cd "%GOPATH%\src\github.com\gopherdata\gophernotes"
go install .
  1. Start again jupyter notebook, and create a new Go notebook with New > Go

  2. Import again the same third-party packages as in step 4. This time gophernotes will find them.

Final note: you need to repeat steps 4,5,6 and 7 each time you want to import third-party packages.
Pretty tedious, but there's currently no other solution.

@cosmos72 cosmos72 self-assigned this Feb 6, 2022
@cosmos72 cosmos72 changed the title windows can't import [Question] How to import third-party packages on Windows? Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants