Page 1 of 1

Python problem on Ubuntu Linux

PostPosted: Fri Feb 02, 2018 10:17 pm
by Dan Bethell
Hi,

Has anyone managed to get Fusion installed and Python working on a flavour of Ubuntu Linux?

Both pythons are installed on my system...
Code: Select all
$ python
Python 2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Code: Select all
$ python3
Python 3.6.3 (default, Oct  3 2017, 21:45:48)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Heck, the Fusion installer even tells me it's found them...
Fusion_PythonInstallProblem.png
Fusion_PythonInstallProblem.png (68.49 KiB) Viewed 863 times

Fusion runs just fine, but when I flip to the Py2 or Py3 Console tab I get an error popup saying 'Python 2.7 not found.' and a similar message for 3.6.
Fusion_PythonInstallProblem2.png
Fusion_PythonInstallProblem2.png (14.96 KiB) Viewed 863 times


I'm running Fusion 9.0.2 and vanilla Ubuntu 17.10 (although found the same problem with 16.04). As far as I can tell the Python installation on this distro is pretty standard - do i need to set a PYTHONPATH or somesuch for Fusion to pick up Python at runtime?

Any help, much appreciated.
Dan

Re: Python problem on Ubuntu Linux

PostPosted: Mon Feb 05, 2018 10:12 pm
by Abdelrahman Magdy
I have tried to get it working, but I failed entirely.. had to move to CentOS mainly because of that, as Blackmagic insisted they don't support any other Linux distro. But keep in mind, on CentOS, I only managed to get Python2.7 to work. I am no where near doing the same with Python3, and the Blackmagic support have been totally clueless about this problem. In Fusion, it says that it needs Python3.6, but their support says that I need Python3.3. I have installed both, and I still couldn't get any of them to work.

Re: Python problem on Ubuntu Linux

PostPosted: Mon May 21, 2018 5:35 am
by gunk0001
not really concern on python3 since python2.7 is still vfx standard.

Re: Python problem on Ubuntu Linux

PostPosted: Tue May 29, 2018 4:32 pm
by Abdelrahman Magdy
gunk0001 wrote:not really concern on python3 since python2.7 is still vfx standard.

Actually, the transition to Python 3 is about to start. According to the VFX Reference Platform, software vendors are encouraged to start releasing tech review versions of their programs with Python 3 support, as the transition is going to happen in 2020.

So, it is not a bad time to start dipping your toe into Python 3. But as I said, 2.7 is working for me on Windows and CentOS, but not on Linux Mint when I last tried it.

Re: Python problem on Ubuntu Linux

PostPosted: Wed Aug 15, 2018 11:11 am
by Jimmy Christensen
I think I found out why it doesn't work in Ubuntu

First it looks for "libpython2.7.so" with `ldconfig -p`

It finds it in "/usr/lib/x86_64-linux-gnu" and then assumes that all the modules are located in "/usr/lib/x86_64-linux-gnu/python2.7" which is not the case as this is in "/usr/lib/python2.7".

If you link "/usr/lib/python2.7" to "/usr/lib/x86_64-linux-gnu/python2.7" it then has some more assumptions and tries to find the python2.7 directory in "/usr/lib/lib"

Re: Python problem on Ubuntu Linux

PostPosted: Sun Sep 16, 2018 11:13 am
by Dan Bethell
Jimmy, that's really useful information! How on earth did you manage to work out/debug what Fusion was doing under the hood??

Using that info I finally managed to get Python2.7 working in Fusion 9 on Ubuntu 18.04. Rather than linking the python module directory (as apparently Fusion assumes everything is relative to the library itself) I sym-linked the shared library instead.
Code: Select all
% sudo ln -s /usr/lib/x86_64-linux-gnu/libpython2.7.so.1 /usr/lib/
Then I added /usr/lib before any other paths in /etc/ld.so.conf.d/x86_64-linux-gnu.conf. After refreshing the ldconfig cache the new sym-linked python shared library appears in /usr/lib.
Code: Select all
% cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
# Multiarch support
/usr/lib
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

% sudo ldconfig

% ldconfig -p | grep python2.7
   libpython2.7.so.1.0 (libc6,x86-64) => /usr/lib/libpython2.7.so.1.0
   libpython2.7.so.1.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
   libpython2.7.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpython2.7.so
Now when I run Fusion the Py2 console gives me no errors and evaluates exactly as I'd expect!
fusion_python_ubuntu.png
fusion_python_ubuntu.png (28.31 KiB) Viewed 328 times

I still haven't had any luck getting Python3 to work using this solution though, so any more insight into debugging Fusions relationship with Python3 would be great!

Re: Python problem on Ubuntu Linux

PostPosted: Wed Sep 19, 2018 7:59 pm
by Chris Wells
Dan, That is super helpful! Thanks so much for posting this. I now have python working on ubuntu :)

So has anyone had any luck talking to fusion from the outside world, the old import BlackmagicFusion doesn't work, But I have not idea where that module actually ended up or where to put it to make it work,

Anyone have any ideas?

Thanks
Chris

Re: Python problem on Ubuntu Linux

PostPosted: Wed Sep 19, 2018 8:52 pm
by Dan Bethell
Ah ok, I left that bit of information out. On installation Fusion will try to install (or rather, symlink) the BlackmagicFusion.py into /usr/lib/python2.7/site-packages, which does not exist by default on Ubuntu (it's called dist-packages instead). The installer doesn't error though, which is not ideal.

There are several ways to get the Blackmagic module into your path but probably the simplest is to mimic what the installer was trying to do...
Code: Select all
sudo ln -s /opt/BlackmagicDesign/Fusion9/BlackmagicFusion.py /usr/lib/python2.7/dist-packages/
That should get import BlackmagicFusion working as expected.

Re: Python problem on Ubuntu Linux

PostPosted: Wed Sep 19, 2018 8:55 pm
by Chris Wells
Thanks Dan All up and working,

Re: Python problem on Ubuntu Linux

PostPosted: Fri Sep 21, 2018 6:31 am
by MikeRochefort
I figured out Python 3.6 on CentOS. You'll need Python from IUS (python36u) or EPEL (python36) installed:

Code: Select all
cd /lib64
sudo ln -s libpython3.6m.so libpython3.6.so
sudo ldconfig


It's the `m` that's throwing it off. After doing so I can switch to Python 3.6 in the preferences just fine.

Cheers,
Mike

Re: Python problem on Ubuntu Linux

PostPosted: Fri Sep 21, 2018 10:32 am
by Abdelrahman Magdy
MikeRochefort wrote:I figured out Python 3.6 on CentOS. You'll need Python from IUS (python36u) or EPEL (python36) installed:

Code: Select all
cd /lib64
sudo ln -s libpython3.6m.so libpython3.6.so
sudo ldconfig


It's the `m` that's throwing it off. After doing so I can switch to Python 3.6 in the preferences just fine.

Cheers,
Mike

Is there a way to use it with the regular python installation (from python.org). I already have it installed with multiple things using it and I don't want go through the pain of re-doing this stuff?

Any ideas?

Re: Python problem on Ubuntu Linux

PostPosted: Fri Sep 21, 2018 1:15 pm
by MikeRochefort
So youbuilt from source? Did you build to /usr/local or some custom path? As long as your python library is on the library search path, just creating a symlink with the incorrect “appropriate” naming will open things up. No need to change anything.

I sent an email to support about this, so they definitely have something to look at.

Cheers,
Mike

Re: Python problem on Ubuntu Linux

PostPosted: Fri Sep 21, 2018 1:49 pm
by Abdelrahman Magdy
MikeRochefort wrote:So youbuilt from source? Did you build to /usr/local or some custom path? As long as your python library is on the library search path, just creating a symlink with the incorrect “appropriate” naming will open things up. No need to change anything.
I built in /usr, so the python executable is in /usr/bin. I have both /usr/lib and /usr/lib64 on the library path.
Code: Select all
> echo $LD_LIBRARY_PATH
/usr/lib /usr/lib64 /usr/lib /usr/lib64
I also have libpython3.6.so in both of them.
Code: Select all
> ll /usr/lib | grep libpython
-r-xr-xr-x.  1 root root  21M Oct 25  2017 libpython3.6m.a
lrwxrwxrwx.  1 root root   20 Mar 17  2018 libpython3.6m.so -> libpython3.6m.so.1.0
-r-xr-xr-x.  1 root root  12M Mar 17  2018 libpython3.6m.so.1.0
lrwxrwxrwx.  1 root root   20 Sep 21 11:29 libpython3.6.so -> libpython3.6m.so.1.0
-r-xr-xr-x.  1 root root 7.6K Mar 17  2018 libpython3.so
Code: Select all
> ll /usr/lib64/ | grep libpython
lrwxrwxrwx.  1 root root     19 Aug  8 03:06 libpython2.7.so -> libpython2.7.so.1.0
-rwxr-xr-x.  1 root root   1.8M Jul 13 14:07 libpython2.7.so.1.0
lrwxrwxrwx.  1 root root     15 Sep 21 11:21 libpython3.6m.so.1.0 -> libpython3.6.so
lrwxrwxrwx.  1 root root     29 Sep 21 11:20 libpython3.6.so -> /usr/lib/libpython3.6m.so.1.0
lrwxrwxrwx.  1 root root     13 Sep 21 11:27 libpython3.so -> libpython3.so
However, I still can't get Python3 to work inside Fusion.

Re: Python problem on Ubuntu Linux

PostPosted: Fri Sep 21, 2018 8:05 pm
by MikeRochefort
Can you run `sudo ldconfig` and see what happens?

Cheers,
Mike

Re: Python problem on Ubuntu Linux

PostPosted: Sat Sep 22, 2018 1:15 am
by Abdelrahman Magdy
MikeRochefort wrote:Can you run `sudo ldconfig` and see what happens?

Cheers,
Mike
Done it, and still nothing, unfortunately :(

Re: Python problem on Ubuntu Linux

PostPosted: Fri Oct 05, 2018 7:45 pm
by limeforce
Thanks for the info Jimmy & Dan! The following worked for me on Linux Mint 18.3.

Add "/usr/lib" to the start of /etc/ld.so.conf.d/x86_64-linux-gnu.conf using:
Code: Select all
sudo vim /etc/ld.so.conf.d/x86_64-linux-gnu.conf
Then symlink the python lib to /usr/lib and refresh config:
Code: Select all
sudo ln -s /usr/lib/x86_64-linux-gnu/libpython2.7.so.1 /usr/lib/x86_64-linux-gnu/libpython2.7.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libpython2.7.so.1 /usr/lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libpython2.7.so /usr/lib/

sudo ldconfig
That's all!

If you want to check your result against mine:
Code: Select all
~ $ cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
# Multiarch support
/usr/lib
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
~ $ sudo ldconfig -p |grep python2
libpython2.7.so.1.0 (libc6,x86-64) => /usr/lib/libpython2.7.so.1.0
libpython2.7.so.1.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
libpython2.7.so (libc6,x86-64) => /usr/lib/libpython2.7.so
libpython2.7.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpython2.7.so
libpyglib-2.0-python2.7.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpyglib-2.0-python2.7.so.0
Note that this only works for Python 2. Also, for a while I was trying another solution at the same time and it was actually preventing this one from working. I had set the environment variables FUSION_PYTHON27_HOME and FUSION_PYTHON36_HOME, as described in this thread:
Code: Select all
http://www.steakunderwater.com/wesuckless/viewtopic.php?f=16&t=1634&p=19796
I had to remove those.

P.S. LOL @ not being able to link to elsewhere on the web in 2018, Blackmagic pls.