# Best/easiest way to downgrade to version 8.4.3, on Linux Ubuntu 20.04

**URL:** <https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966>\
**Category:** Installing\
**Created:** [November 25, 2022, 1:06pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966 "2022-11-25T13:06:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [November 25, 2022, 1:06pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/1 "2022-11-25T13:06:53Z")

</div>

Yesterday, the new stable PPA version (9.0.0) was released. That’s great, but this breaks Popper ([GitHub - logic-and-learning-lab/Popper: Popper is an inductive logic programming (ILP) system.](https://github.com/logic-and-learning-lab/Popper)) which relies on the Python pyswip package to bridge between Python and SWI Prolog ([GitHub - yuce/pyswip: PySwip is a Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.](https://github.com/yuce/pyswip)).

The pyswip package worked with the previous stable version of SWI Prolog (8.4.3), so I wonder if there’s a quick fix of downgrading to this SWI Prolog version.

(I’ve also filed an issue on the Popper repo on this, [Problem with SWI Prolog's new stable PPA version 9.0.0 (Linux Ubuntu) · Issue #55 · logic-and-learning-lab/Popper · GitHub](https://github.com/logic-and-learning-lab/Popper/issues/55) . It does not help to downgrade to another pyswip version.)

---

<div class="post-metadata">

**Author:** ![Boris](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/boris/32/7486_2.png) [@Boris](https://swi-prolog.discourse.group/u/Boris)\
**Post date:** [November 25, 2022, 1:30pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/2 "2022-11-25T13:30:09Z")

</div>

If you are using the Ubuntu package manager for this you should probably search their docs for downgrading. I don’t know for certain but most package managers have some process to do exactly that. Maybe you have the previous package downloaded and need to downgrade? or maybe you need to install a specific version?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 25, 2022, 1:37pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/3 "2022-11-25T13:37:38Z")

</div>

There is some discussion on how to install older PPA versions at [apt - Getting older packages from ppa - Ask Ubuntu](https://askubuntu.com/questions/231074/getting-older-packages-from-ppa)

If I recall correctly, the problem with pyswip is that it hard-codes the C types and constants from SWI-Prolog.h in the Python code. But, running `git diff -b V8.4.3 SWI-Prolog.h` says nothing changed between 8.4.3 and 9.0.0, only some new stuff was added. So I wonder why pyswip is broken? Is it looking for `libswipl.so.8`?

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [November 25, 2022, 4:10pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/4 "2022-11-25T16:10:06Z")

</div>

Thanks for the suggestion. However, Ubuntu’s own repo has a much older SWI Prolog version (v7.6.4) which does not work with pyswip.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 25, 2022, 4:28pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/5 "2022-11-25T16:28:52Z")

</div>

The PPA archive contains all versions. See [https://launchpad.net/~swi-prolog/+archive/ubuntu/stable/+builds?build\_state=built](https://launchpad.net/~swi-prolog/+archive/ubuntu/stable/+builds?build_state=built). The previous link I gave says how to install a particular version. If this fails you can simply download the `.deb` and use `dpkg -i file.deb`.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [November 25, 2022, 4:38pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/6 "2022-11-25T16:38:25Z")

</div>

What I can see, pyswip (in core.py) is looking for ‘libswipl.so’ and ‘libpl.so’, so the specific SWI Prolog version is not hard coded.

Regarding downgrading via PPA, do you know exactly what version name to use when specifying the version via apt-get? The syntax is `apt-get install pkg=version` but I don’t know the exact version name to use.

I was trying `sudo apt install swi-prolog=swi-prolog_8.4.2` but it was not found.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [November 25, 2022, 4:55pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/7 "2022-11-25T16:55:34Z")

</div>

Thanks, Jan.

It worked using the packages from [amd64 build of swi-prolog 8.4.3-1-g10c53c6e3-focalppa2 : SWI-Prolog stable : “SWI Prolog” team](https://launchpad.net/~swi-prolog/+archive/ubuntu/stable/+build/24099974) (the focal distribution since I’m on Ubuntu 20.04).

Note for self (and perhaps some other): The packages must be installed in this order:

```prolog
sudo dpkg -i swi-prolog-nox_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb
sudo dpkg -i swi-prolog-x_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb
sudo dpkg -i swi-prolog_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 27, 2022, 9:56am UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/8 "2022-11-27T09:56:30Z")

</div>

I’m wondering what is wrong. The Prolog interface seems to load fine into Python using SWI-Prolog 9.0.0.

I did look at how pyswip loads libswipl. That can be improved. Following similar issues with sweep, there is now a flag `libswipl` that points at the shared object used by `swipl` (if any). I improved that a bit such that it is now fully reliable on Windows, MacOS and Linux (and other POSIX systems providing `dladdr()`) and make it available through `swipl --dump-runtime-variables`. I’ll make a PR on pyswip to use that as first choice.

But again, this does not seem to be the problem. That is to be expected as the installation locations have not changed and the interface should be fully binary compatible between 8.4.x and 9.0.x

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [November 27, 2022, 10:44am UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/9 "2022-11-27T10:44:34Z")

</div>

Thanks for looking into this, Jan.

The source of the problem seems be the one mentioned in pyswip PR 133 ([Support SWI-Prolog versions \> 8.5.2 by david-r-cox · Pull Request #133 · yuce/pyswip · GitHub](https://github.com/yuce/pyswip/pull/133)), i.e. that pyswip tries to first check SWI Prolog’s `PL_version` instead of `PL_version_info`-

I did the following in my pyswip source:

```prolog
diff --git a/pyswip/core.py b/pyswip/core.py
index 33f7035..0bb992f 100644
--- a/pyswip/core.py
+++ b/pyswip/core.py
@@ -584,7 +584,7 @@ PL_VERSION_VM =6 # VM signature
 PL_VERSION_BUILT_IN =7 # Built-in predicate signature
 
 try:
- PL_version = _lib.PL_version
+ PL_version = _lib.PL_version_info
     PL_version.argtypes = [c_int]
     PL_version.restype = c_uint

```

and installed this version (after `pip uninstall pyswip` to remove all previous installations).

Now pyswip works with SWI Prolog version 9.0.0 (PPA stable version)! That’s great.

(The proper fix would probably be to check for some older version of SWI Prolog.)

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 27, 2022, 11:40am UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/10 "2022-11-27T11:40:15Z")

</div>

Thanks. Created a PR [Comparing yuce:master...JanWielemaker:find-libswipl · yuce/pyswip · GitHub](https://github.com/yuce/pyswip/compare/master...JanWielemaker:pyswip:find-libswipl?expand=1) that uses a new mechanism to find `libswipl`, falling back to trying the whole platform specific heuristics used in pyswip.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [November 27, 2022, 11:47am UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/11 "2022-11-27T11:47:23Z")

</div>

That’s great, Jan.

Let’s hope that the pyswip gang applies your fix soon.

---

<div class="post-metadata">

**Author:** ![crgz](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/crgz/32/6144_2.png) [@crgz](https://swi-prolog.discourse.group/u/crgz)\
**Post date:** [November 28, 2022, 6:36pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/12 "2022-11-28T18:36:56Z")

</div>

Thanks @hakank, @Boris & @jan !

I found that the community-maintained (universe) package sources needs to be enabled before instaling the package requirements to downgrade to the previous stable version of SWI Prolog (8.4.3) in Ubuntu 20.04 based docker images:

```prolog
add-apt-repository "deb http://archive.ubuntu.com/ubuntu focal main universe restricted multiverse"
apt-get install -y libarchive13 libossp-uuid16 libgmp-dev libedit-dev libreadline-dev libncursesw5-dev libjs-jquery
dpkg -i swi-prolog-nox_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb

```

Does anyone know a cleaner way to downgrade until the [PySwip fix](https://github.com/yuce/pyswip/pull/145) get applied?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 28, 2022, 9:01pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/13 "2022-11-28T21:01:20Z")

</div>

> [@crgz](#):
>
> Does anyone know a cleaner way to downgrade until the [PySwip fix](https://github.com/yuce/pyswip/pull/145) get applied?

Patching pyswip might be easier than downgrading. Just replace PL\_version in core.py by PL\_version\_info and all is fine.

```
 Cheers --- Jan

```

---

<div class="post-metadata">

**Author:** ![AmrSol](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/amrsol/32/4991_2.png) [@AmrSol](https://swi-prolog.discourse.group/u/AmrSol)\
**Post date:** [November 29, 2022, 7:36pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/14 "2022-11-29T19:36:24Z")

</div>

Might sound like a silly question but is there a macOS equivalent of downgradingSWI Prolog?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 29, 2022, 9:09pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/15 "2022-11-29T21:09:35Z")

</div>

> [@AmrSol](#):
>
> macOS equivalent of downgradingSWI Prolog

Depends how you installed it (download binary, Macports, Homebrew, built from source …) For the binary from the download page, download an older version and install it. Use the _show all files_ at the bottom-right of the table to see all versions.

Of course, the question is “why?”. 9.x should be pretty compatible. So far only the pyswip issue came up, but that is fixed with a very simple edit in the pyswip package.

---

<div class="post-metadata">

**Author:** ![crgz](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/crgz/32/6144_2.png) [@crgz](https://swi-prolog.discourse.group/u/crgz)\
**Post date:** [November 30, 2022, 12:33pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/16 "2022-11-30T12:33:12Z")

</div>

I think the challenge might be making that simple edit in the pyswip package available in our production continuous delivery pipelines. They are built around the Python Package Index at [pypi.org](http://pypi.org) and Personal Package Archives for Ubuntu at [launchpad.net](http://launchpad.net) and companies feel confident integrating software from well-known sources.

I can imagine an ideal world where changes, including new versions in utilities like SWI-Prolog, trigger automated tests in dependency-using tools like PySwip so that the communities that support those tools can react faster to integration issues, merge the changes and release them through well known distribution channels.

---

<div class="post-metadata">

**Author:** ![AmrSol](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/amrsol/32/4991_2.png) [@AmrSol](https://swi-prolog.discourse.group/u/AmrSol)\
**Post date:** [November 30, 2022, 3:31pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/17 "2022-11-30T15:31:02Z")

</div>

I installed it through Homebrew. The problem I am faced with is that after reinstalling pyswip with your PR: #145 included, I am stilling getting the same error messages before the PR and after updating to 9.x. They are shown below:

File “/Users/amrsoliman/Documents/GitHub/mila/utils\_modified.py”, line 15, in learn  
prolog.consult(file\_name)  
File “/Users/amrsoliman/miniforge3/envs/M1/lib/python3.9/site-packages/pyswip/prolog.py”, line 168, in consult  
next(cls.query(filename.join([“consult('”, “')”]), catcherrors=catcherrors))  
File “/Users/amrsoliman/miniforge3/envs/M1/lib/python3.9/site-packages/pyswip/prolog.py”, line 128, in **call**  
raise PrologError(“”.join([“Caused by: '”, query, "'. ",  
pyswip.prolog.PrologError: Caused by: ‘consult(‘train.pl’)’. Returned: ‘error(instantiation\_error, context(:(system, /(atom\_chars, 2)), \_3208))’.

I’m not sure how to fix it…

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [November 30, 2022, 3:59pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/18 "2022-11-30T15:59:44Z")

</div>

If I do `pip install pyswip -U` I still see the old version. My patch is actually irrelevant, it merely makes finding the shared object more robust for future versions. The one that really matters is [Support SWI-Prolog versions \> 8.5.2 by david-r-cox · Pull Request #133 · yuce/pyswip · GitHub](https://github.com/yuce/pyswip/pull/133)

And the simple quick fix is to find `core.py` in the package and replace `PL_version` with `PL_version_info`.

These may be unrelated to your problem though. It seems you can create an instance of Prolog. Without some context on what is supposed to happen I can’t comment on these errors (and anyway, my Python knowledge is not much).

---

<div class="post-metadata">

**Author:** ![AmrSol](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/amrsol/32/4991_2.png) [@AmrSol](https://swi-prolog.discourse.group/u/AmrSol)\
**Post date:** [November 30, 2022, 4:49pm UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/19 "2022-11-30T16:49:05Z")

</div>

It finally works! Here is how:

For some reason downloading SWI-Prolog 8.4.3 from the website is causing me another slew of errors. Therefore I went back to SWI-Prolog 9.x via homebrew.

By implementing D.Cox’s PR #133, I get the “Exception: swi-prolog version number could not be determined”.

Then I implemented @hakank 's suggestion by amending Cox’s “PL\_version = \_lib.PL\_version” to “PL\_version = \_lib.PL\_version\_info”

Viola! Thankfully, it works! In case anyone is curious, I have been using Aleph.

---

<div class="post-metadata">

**Author:** ![crgz](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/crgz/32/6144_2.png) [@crgz](https://swi-prolog.discourse.group/u/crgz)\
**Post date:** [December 23, 2022, 10:16am UTC](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/21 "2022-12-23T10:16:40Z")

</div>

Hi Jan!

Do you know why the package **swi-prolog-nox\_8.4.3-1-g10c53c6e3-focalppa2\_amd64.deb** is not longer available in the [usual URL](https://launchpad.net/~swi-prolog/+archive/ubuntu/stable/+build/24099974)? Do you know an alternative way to get this package?

Thanks and regards!

 ![Screenshot from 2022-12-21 14-10-40-arrow](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/6/6aec99458eab63226e95f1534fac911222065b12.png)

[Next page](https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966.md?page=2)
