Old 03-24-2023, 07:30 PM   #1
mrmong
Human being with feelings
 
Join Date: Oct 2021
Posts: 36
Default Reaper crashes on import for any python libraries

Hello! I'm very new to scripting in python for reascript and i haven't had much luck for being able to run a script that imports libraries

for context, i'll need to import some libraries such as pandas or openpyxl to parse some excel xls data

Reaper seems to hang immediately when theres a line such as import pandas as pd

Would love to get some help if anyone have encountered this before



i'm on python 3.10 and have these versions installed and listed

openpyxl 3.1.2
pandas 1.5.3
mrmong is offline   Reply With Quote
Old 03-25-2023, 04:24 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 10,085
Default

Python modules loading doesnt works well with reaper python script.


You have to use a wrapper for these

https://github.com/RomeoDespres/reapy
X-Raym is offline   Reply With Quote
Old 03-25-2023, 07:05 AM   #3
mrmong
Human being with feelings
 
Join Date: Oct 2021
Posts: 36
Default

Ah ok! Ill give it a shot!

Im writing some scripts that parses xlsx and then run through the regions and markers in session to update them.

A question i have although its abit out of topic but related would be, since this python script require additional libraries to run, how would one make it portable in the sense where new users don’t have to install additional stuff and can just grab my reaper portable package and run the scripts?
mrmong is offline   Reply With Quote
Old 03-25-2023, 07:09 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 10,085
Default

Your python script need, pythons libraries, python itself, reapy and the script. The first two can't be shared via your reaper config.


It would be more efficient to just do a Lua script.
Though you might consider working on CSV file instead of XLS, cause Lua from XLS is a bit unexplored (as CSV is just better for such things) https://forum.cockos.com/showthread.php?t=276270

Last edited by X-Raym; 03-25-2023 at 08:33 AM.
X-Raym is offline   Reply With Quote
Old 03-25-2023, 07:14 AM   #5
mrmong
Human being with feelings
 
Join Date: Oct 2021
Posts: 36
Default

Quote:
Originally Posted by X-Raym View Post
Your python script need, pythons libraries, python itself, and the script. The first two can't be shared via your reaper config.


It would be more efficient to just do a Lua script.
Though you might consider working on CSV file instead of XLS, cause Lua from XLS is a bit unexplored (as CSV is just better for such things) https://forum.cockos.com/showthread.php?t=276270

Yeah thats true.. i was digging around for xlsx to lua parsers but didnt have much luck making any work unfortunately.. i had the csv update script ready but having the files converted to csv isnt really an option for my team unfortunately..
mrmong is offline   Reply With Quote
Old 03-26-2023, 07:30 AM   #6
mrmong
Human being with feelings
 
Join Date: Oct 2021
Posts: 36
Default

EDIT

I managed to fixed this by completely uninstalling python, clearing the pip cache and then installing python again while checking the 'add to PATH" during the installation screen. Seems like the previous installations was causing some confusion with python when its trying to import the libraries!

Last edited by mrmong; 03-26-2023 at 08:14 AM.
mrmong is offline   Reply With Quote
Old 03-26-2023, 08:50 AM   #7
Starshine
Human being with feelings
 
Join Date: Jan 2023
Posts: 58
Default

Quote:
Originally Posted by mrmong View Post
EDIT

I managed to fixed this by completely uninstalling python, clearing the pip cache and then installing python again while checking the 'add to PATH" during the installation screen. Seems like the previous installations was causing some confusion with python when its trying to import the libraries!
In the year 3023, the files finding the other files (sometimes literally in the same directory) on the same computer will continue to be the most difficult thing >__<
Starshine is offline   Reply With Quote
Old 03-26-2023, 09:02 AM   #8
Starshine
Human being with feelings
 
Join Date: Jan 2023
Posts: 58
Default

Quote:
Originally Posted by mrmong View Post
Ah ok! Ill give it a shot!

Im writing some scripts that parses xlsx and then run through the regions and markers in session to update them.

A question i have although its abit out of topic but related would be, since this python script require additional libraries to run, how would one make it portable in the sense where new users don’t have to install additional stuff and can just grab my reaper portable package and run the scripts?
I'm interested in the topic generally because I'm going to be converting file formats (to and from MIDI and other sources), interacting with the project, loading data into memory for JSFX to do stuff with, etc. -- still pretty new to this myself but I might be able to help. Might need a bit more context to know what's potentially a solution that's not out of reach. Let me know if you haven't got something figured out yet!
Starshine is offline   Reply With Quote
Old 03-26-2023, 02:19 PM   #9
mrmong
Human being with feelings
 
Join Date: Oct 2021
Posts: 36
Default

Quote:
Originally Posted by Starshine View Post
In the year 3023, the files finding the other files (sometimes literally in the same directory) on the same computer will continue to be the most difficult thing >__<
I know right! its still quite a pain in the ass to configure something to get started :’)


Quote:
Originally Posted by Starshine View Post
I'm interested in the topic generally because I'm going to be converting file formats (to and from MIDI and other sources), interacting with the project, loading data into memory for JSFX to do stuff with, etc. -- still pretty new to this myself but I might be able to help. Might need a bit more context to know what's potentially a solution that's not out of reach. Let me know if you haven't got something figured out yet!
Normally i would have just stuck to using lua since there isnt much dependencies on loading extra libraries but for this case…i couldnt find anything else that i can easily parse the excel sheet to lua hence python. On my end im running portable versions of reaper so that anyone on my team can grab and go to use once the package is ready without any installation needed. But for this case I suppose my only solution is to get them to install python & openpyxl libraries as a criteria…(or even writing a bat file to install all the stuff required) unless anyone have a better solution
mrmong is offline   Reply With Quote
Old 03-26-2023, 03:32 PM   #10
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 10,085
Default

  • try to find other lua xls parsers
  • fix one the Lua library you tried
  • use a cli tool to handle conversion under the hood
  • code your own Lua XLS parser

You didnt mentioned which ones you tried 😉

When I say 'fix' or 'code', you can also consider sponsored developement to ask someone else to do it.
X-Raym is offline   Reply With Quote
Old 03-26-2023, 04:01 PM   #11
mrmong
Human being with feelings
 
Join Date: Oct 2021
Posts: 36
Default

Quote:
Originally Posted by X-Raym View Post
  • try to find other lua xls parsers
  • fix one the Lua library you tried
  • use a cli tool to handle conversion under the hood
  • code your own Lua XLS parser

You didnt mentioned which ones you tried 😉

When I say 'fix' or 'code', you can also consider sponsored developement to ask someone else to do it.

Still digging around to see what other lua xls parsers are floating around on the web

I’ve tried a couple like luacom, luaxlsx
but im often met with either compile errors or something funky that doesnt want to load.

With luacom i was met with “not a valid win32 application” and couldnt compile a 64bit version either
Luaxlsx from this link https://github.com/xiyoo0812/luaxlsx didnt seem to work either with a bunch of modules/.lua files not found and i cant figure how to load this one either with the many errors.

Ill take a look at the cli tool to do something under the hood! Thanks for the suggestion!

I think for now ill run with python unless someone have any hints on the xlsx parser~

Last edited by mrmong; 03-26-2023 at 04:07 PM.
mrmong is offline   Reply With Quote
Old 03-26-2023, 10:39 PM   #12
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 10,085
Default

Loading lua modules in C also has problems in reaper,
The Lua Batteries thread has some infos about this :
https://forum.cockos.com/showthread.php?t=267360


The 'easy' solution would be a lua xls parser in Lua file in reaper, not in a dll, if such thing exist (or if it has to be coded).

But converting under the hood into csv with cli may be even simpler.
X-Raym is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.