tin2tin / Blender_Screenwriter

Blender add-on for writing screenplays and convert them directly into timed storyboards.
193 stars 21 forks source link

Linux export - installation of Screenplain fails #10

Closed AndreaMonzini closed 3 years ago

AndreaMonzini commented 5 years ago

Hi, tested the export but there is an error about the module screenplain: Tested in 2.81 ( GNU/Linux)

Traceback (most recent call last):
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 534, in screenplay_export
    import screenplain
ModuleNotFoundError: No module named 'screenplain'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/http/client.py", line 1290, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/http/client.py", line 1239, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/http/client.py", line 1414, in connect
    server_hostname=server_hostname)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 513, in execute
    self.open_browser)
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 543, in screenplay_export
    urllib.urlretrieve(url, home_url + 'screenplain-0.8.0.zip')
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/urllib/request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)>

location: <unknown location>:-1

location: <unknown location>:-1
AndreaMonzini commented 5 years ago

i tried to look the code,maybe the problem is that the Linux path is " / " and not " \ " so the screenplain module is not installed correctly: Referred to Blender_Screenwriter.py line 542: home_url = bpy.utils.script_path_user() + "\\addons\\"

tin2tin commented 5 years ago

Let me know if that solves it on Linux?

AndreaMonzini commented 5 years ago

i changed home_url = bpy.utils.script_path_user() + "\\addons\\" to home_url = bpy.utils.script_path_user() + "//addons//"

But same errors. I cannot find Screenplain as downloaded or installed If i manually download screenplain-0.8.0.zip and copy the screenplain folder in the addon folder i have this error:

Traceback (most recent call last):
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 513, in execute
    self.open_browser)
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 552, in screenplay_export
    import screenplain.parsers.fountain as fountain
  File "/home/linux/.config/blender/2.81/scripts/addons/screenplain/parsers/fountain.py", line 8, in <module>
    from six import next
ModuleNotFoundError: No module named 'six'

location: <unknown location>:-1

location: <unknown location>:-1
tin2tin commented 5 years ago

I don't know anything about Linux, but you probably do not have to use double // when they are turning that way.

Copying it to the add-on folder is what the add-on does and it works on Windows. Well actually it's the same way fountain.py is used by the add-on.

Have you tried to Google that error? (I'm not at my computer right now)

tin2tin commented 5 years ago

A moment at the computer. Seems like you're missing a module called six.

It can be installed using these instructions, but of course installing six instead pycodestyle: https://github.com/tin2tin/Python_Stylechecker_for_Blender

For reference: https://pypi.org/project/six/

AndreaMonzini commented 5 years ago

I was able to install pip and six, thank you. But still not work, probably i have to check the right path for the installation. Now is in pip3 install six Requirement already satisfied: six in /usr/lib/python3/dist-packages (1.12.0)

i checked in library and i have installed Python 2.7, 3, 3.7 and 3.8. i need to investigate more.

tin2tin commented 5 years ago

It is using the Python which comes with Blender. So you must run the pip command in the console in the Blender Python folder: image

Screenplain can also be installed this way, but I would be happy if you could find a way to get the BSW to do it on Linux.

tin2tin commented 5 years ago

Does the add-on work if you install screenplain with pip?

AndreaMonzini commented 5 years ago

I installed screenplain with pip Requirement already satisfied: six in /usr/lib/python3/dist-packages (from screenplain) (1.12.0) Installing collected packages: screenplain Successfully installed screenplain-0.8.0 but still far for working

tin2tin commented 5 years ago

And installed from the Blender Python bin?

AndreaMonzini commented 5 years ago

I am searching to installing it using Blender Python console, but in Linux is a bit different. i do not have a Python.exe in the blender Python folder so i am trying to run it with ./

tin2tin commented 5 years ago

https://blender.stackexchange.com/questions/108283/how-to-load-external-modules-packages-into-blender-python/140343#140343

Did you remember the: -m

AndreaMonzini commented 5 years ago

Blender Pyhton does not recognise pip or pip3:

linux@pop-os:~$ '/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m' pip3 -m install screenplain /home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m: can't open file 'pip3': [Errno 2] No such file or directory

AndreaMonzini commented 5 years ago

no luck for now: linux@pop-os:~$ '/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m' -m pip install screenplain /home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m: No module named pip

tin2tin commented 5 years ago

Ah, try to download and place this file in the folder with the Blender python exe: https://bootstrap.pypa.io/get-pip.py

And then run it from the command line with python "get-pip.py"

Or else try the ensurepip etc. stuff from here: https://blender.stackexchange.com/questions/108283/how-to-load-external-modules-packages-into-blender-python/140343#140343

AndreaMonzini commented 5 years ago

I just enabled ensurepip

linux@pop-os:~$ '/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m' -m ensurepip
Looking in links: /tmp/tmp1wqxim2q
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0
AndreaMonzini commented 5 years ago

Finally Works! Many thanks!

For other Linux users the commands that worked for me:

https://blender.stackexchange.com/questions/108283/how-to-load-external-modules-packages-into-blender-python/140343#140343

html

tin2tin commented 5 years ago

Bingo! If you want to test the pdf output, you can search for pdf and find some commented out code in Blender_Screenwriter.py which just needs to be inserted to get it to become an export option. I suspect that it is also module related.

Could you do me a favour at use pip to uninstall screenplain again, and then try to install it with BSW.py and see it it succeds now? (Then you can install screenplain again afterwards)

AndreaMonzini commented 5 years ago

Sure now is uninstalled. linux@pop-os:~$ '/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m' -m pip uninstall screenplain Uninstalling screenplain-0.8.0: Would remove: /home/linux/.local/bin/screenplain /home/linux/.local/lib/python3.7/site-packages/screenplain-0.8.0.dist-info/* /home/linux/.local/lib/python3.7/site-packages/screenplain/* Proceed (y/n)? y Successfully uninstalled screenplain-0.8.0

AndreaMonzini commented 5 years ago

But this the error when i try to export:

Traceback (most recent call last):
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 513, in execute
    self.open_browser)
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 560, in screenplay_export
    convert(screenplay, output, bare=False)
  File "/home/linux/.local/lib/python3.7/site-packages/screenplain/export/html.py", line 185, in convert
  File "/home/linux/.local/lib/python3.7/site-packages/screenplain/export/html.py", line 194, in convert_full
FileNotFoundError: [Errno 2] No such file or directory: '/home/linux/.local/lib/python3.7/site-packages/screenplain/export/default.css

`

tin2tin commented 5 years ago

So it is not looking in the addons folder for the screenplain files? But properly where it was installed with pip.

Hmmm... I hope we can find better way than using pip in the console, but if not, could you write how to do it on Linux, so we can put in on the main page?

AndreaMonzini commented 5 years ago

I un-commented the PDF, saved, restarted blender, export but i do not see PDF export options:

export

AndreaMonzini commented 5 years ago

To install screenplain using GNU/Linux with Blender Python i used 2 commands with the terminal: 1: '/INSTALLED_BLENDER_PATH/2.81/python/bin/python3.7m' -m ensurepip 2: '/INSTALLED_BLENDER_PATH/2.81/python/bin/python3.7m' -m pip install screenplain

tin2tin commented 5 years ago

You need to place the (pdf etc.) inbetween the html and the fdx stuff. in the following line.

NB. You'll need to install a different version of screenplain for pdf: https://github.com/vilcans/screenplain (which installs additional modules)

AndreaMonzini commented 5 years ago

I installed 'screenplain[PDF]', thank you: '/INSTALLED_BLENDER_PATH/2.81/python/bin/python3.7m' -m pip install 'screenplain[PDF]'

linux@pop-os:~$ '/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/bin/python3.7m' -m pip install 'screenplain[PDF]'
Requirement already satisfied: screenplain[PDF] in ./App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/site-packages (0.8.0)
Requirement already satisfied: six in ./App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/site-packages (from screenplain[PDF]) (1.13.0)
Collecting reportlab; extra == "pdf" (from screenplain[PDF])
  Downloading https://files.pythonhosted.org/packages/c2/bb/7f93a025df23706cc2a8b89f53764accfd480da295c026a1fb815199ade9/reportlab-3.5.32-cp37-cp37m-manylinux1_x86_64.whl (2.6MB)
    100% |████████████████████████████████| 2.6MB 1.2MB/s 
Collecting pillow>=4.0.0 (from reportlab; extra == "pdf"->screenplain[PDF])
  Downloading https://files.pythonhosted.org/packages/89/3e/31c2e5385d7588016c6f7ac552e81c3fff2bef4bc61b6f82f8177752405c/Pillow-6.2.1-cp37-cp37m-manylinux1_x86_64.whl (2.1MB)
    100% |████████████████████████████████| 2.1MB 1.2MB/s 
Installing collected packages: pillow, reportlab
Successfully installed pillow-6.2.1 reportlab-3.5.32

But i receive these errors after i export to PDF:

Traceback (most recent call last):
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 512, in execute
    self.open_browser)
  File "/home/linux/.config/blender/2.81/scripts/addons/Blender_Screenwriter.py", line 565, in screenplay_export
    to_pdf(screenplay, output)
  File "/home/linux/.local/lib/python3.7/site-packages/screenplain/export/pdf.py", line 277, in to_pdf
    doc.build(story)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/site-packages/reportlab/platypus/doctemplate.py", line 1082, in build
    self._endBuild()
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/site-packages/reportlab/platypus/doctemplate.py", line 1017, in _endBuild
    if getattr(self,'_doSave',1): self.canv.save()
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/site-packages/reportlab/pdfgen/canvas.py", line 1244, in save
    self._doc.SaveToFile(self._filename, self)
  File "/home/linux/App/blender-2.81-0a0d735acd6e-linux-glibc217-x86_64/2.81/python/lib/python3.7/site-packages/reportlab/pdfbase/pdfdoc.py", line 222, in SaveToFile
    f.write(data)
TypeError: string argument expected, got 'bytes'
tin2tin commented 5 years ago

iirc is that the same error I'm getting. Can you get pdf conversion to work using the command line(I couldn't)?

AndreaMonzini commented 5 years ago

ok i exported to pdf from command line after installing screenplain in /usr/local/bin

linux@pop-os:~$ sudo pip3 install screenplain
Collecting screenplain
  Downloading https://files.pythonhosted.org/packages/36/07/0948dda71c4663cf579fbeaf722ac42f61f93bcf46b183fcbef455b7c990/screenplain-0.8.0-py2.py3-none-any.whl
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from screenplain) (1.12.0)
Installing collected packages: screenplain
Successfully installed screenplain-0.8.0

using screenplain from /usr/local/bin/screenplain ( not the screenplain module in Blender) Avoid character like "&" in the .fountain name or the are errors

linux@pop-os:~$ screenplain --format pdf test.fountain test.pdf :

fountainpdf

AndreaMonzini commented 5 years ago

i found similar error: https://github.com/vilcans/screenplain/issues/47

tin2tin commented 5 years ago

For reference on installing using PIP: https://developer.blender.org/T71420 Maybe Jacques' solution can be used for installing external modules like Screenplain, instead of the current solution which apparently fails on Linux?

AndreaMonzini commented 5 years ago

I think that Jacques' solution could be very useful, i hope it is compatible with text editor too. Anyway i am using VSCodium when necessary:

https://github.com/VSCodium/vscodium

https://github.com/VSCodium/vscodium/releases

tin2tin commented 3 years ago

This may have been fixed, but I'm not on Linux, so I can't test. Can anyone help me with this?