Skip to content

Commit f26bfaa

Browse files
author
Randall C. O'Reilly
committed
more troubleshooting
1 parent 46553be commit f26bfaa

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ To [install python modules](https://packaging.python.org/tutorials/packaging-pro
3535
python3 -m pip install --upgrade setuptools wheel
3636
```
3737

38+
IMPORTANT: many errors will be avoided by specifying the `-vm` option to gopy, with a full path if needed, or typically just `-vm=python3` to use python3 instead of version 2, which is often the default for the plain `python` command.
39+
40+
### Linux
41+
42+
On linux, you may need to ensure that the linker `ld` will look in the current directory for library files -- add this to your `.bashrc` file (and `source` that file after editing, or enter command locally):
43+
44+
```sh
45+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
46+
```
47+
3848
### Windows
3949

4050
As of version 0.4.0, windows is now better supported, and is passing tests (on at least one developers machine). You may still need to set some environment variables depending on your python installation, but a vanilla standard install is working.
@@ -63,6 +73,8 @@ Documentation is available on [godoc](https://godoc.org):
6373

6474
The `pkg` and `exe` commands are for end-users and create a full standalone python package that can be installed locally using `make install` based on the auto-generated `Makefile`. Theoretically these packages could be uploaded to https://pypi.org/ for wider distribution, but that would require a lot more work to handle all the different possible python versions and coordination with the Go source version, so it is much better to just do the local make install on your system. The `gen` and `build` commands are used for testing and just generate / build the raw binding files only.
6575

76+
IMPORTANT: many errors will be avoided by specifying the `-vm` option to gopy, with a full path if needed, or typically just `-vm=python3` to use python3 instead of version 2, which is often the default for the plain `python` command.
77+
6678
Here are some (slightly enhanced) docs from the help command:
6779

6880
```sh
@@ -164,7 +176,6 @@ Options:
164176

165177
```
166178
167-
168179
## Examples
169180
170181
### From the command line
@@ -179,7 +190,6 @@ $ ls out
179190
Makefile __init__.py __pycache__/ _hi.so* build.py go.py hi.c hi.go hi.py hi_go.h hi_go.so
180191
```
181192
182-
183193
```sh
184194
$ cd out
185195
$ python3
@@ -244,12 +254,28 @@ To know what features are supported on what backends, please refer to the
244254
245255
## Troubleshooting
246256
257+
### python version mismatches
258+
259+
Many errors will be avoided by specifying the `-vm` option to gopy, with a full path if needed, or typically just `-vm=python3` to use python3 instead of version 2, which is often the default for the plain `python` command.
260+
261+
If you get any kind of error about the library module not being able to be imported, or apparently a large number of other random-looking errors, a mismatch between the python version used for compiling vs. what you are using to run is the most likely explanation.
262+
247263
If you get an error like this after importing a generated module:
248264
```bash
249265
Fatal Python error: _PyInterpreterState_Get(): no current thread state
250266
```
251267
it means you are running a different version of python than the one that build the library you are importing -- make sure you've got the paths in your `-vm` arg aligned with what you are using to import.
252268
269+
### linux: cannot find .so file
270+
271+
If your `import` statement fails to find the module `.so` file, and it is in the current directory, you may need to ensure that the linker `ld` will look in the current directory for library files -- add this to your `.bashrc` file (and `source` that file after editing, or enter command locally):
272+
273+
```sh
274+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
275+
```
276+
277+
you may also need to add your python path, but that is less likely to be an issue.
278+
253279
## Contribute
254280
255281
`gopy` is part of the `go-python` organization and licensed under `BSD-3`.

0 commit comments

Comments
 (0)