Jump to content

LeifJP

Member
  • Posts

    5
  • Joined

  • Last visited

Posts posted by LeifJP

  1. Hi,

    I encountered an issue with a workflow I use that creates small preview tiles and saves them into a Markdown file for Obsidian. Suddenly, the script was unable to load the external libraries I had been using. Attempting to reinstall them via pip3 on the command line (I'm using a Mac M1 running macOS 14.4 with Python installed via Homebrew) resulted in the error message: 'error: externally-managed-environment.' However, I was able to resolve the issue by creating a virtual environment and installing the libraries there. Since I couldn't find a solution through Google, I developed a workaround.

    Here's how I did it:

    Inside the Workflow folder (e.g., ~/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow....), create a virtual environment via the terminal.

    Install the necessary libraries using pip.

    Call my script using a zsh script action within the workflow, like this:

        

    # Get the URL from the previous action
    url={query}
    
    # activate the virtual environment
    source env/bin/activate
    
    # run the python script and put the result into the variable markdown
    markdown=$(python3 script.py "$url")
    
    # deactivate the virtual environment
    deactivate
    
    # output of the result for the next action
    echo "$markdown"

     

    Do you think there might be another way to approach this issue? I'm aware that one potential solution could involve calling pip with the option --break-system-packages, but ultimately, using a virtual environment seems like the better solution to me.

    If you can read german, I wrote something more detailed in my blog https://bit.ly/48PRTwe.

  2. Hi.

    I was stuggling with a python script, that runs as external script (with the brew installed version of python) very well, but not when switch back to python3 (and the default old version installed on Venture) in the script menu. How can I use the newer (brew)-version as well. Also putting in shebang on top of the  with the path to the brew version of python work. The funny thing, in the script popup I could choose the brew installed version of php. Is the a work around or any possiblity to customize the script menu or creating in python environment for running a script in Alfred?

     

    Thanks,

    Leif 

  3. On 11/6/2022 at 12:45 PM, vitor said:

    Welcome @LeifJP,

     

    The workflow has icons, more nested prefpanes, and corrects others Ventura broke. You don’t have to use the workflow if you’re not bothered by any of the Ventura changes and don’t need the extra niceties, it exists for those who care about any of that.

    Hi Vitor,

     

    sorry if i offended you. But the question was serious meant. Maybe my English is not so good. But you answered my question, so I'm fine. Never the less maybe you should add that explanation to your workflow page in Alfred.app. 

    So sorry again and thanx for your work,

    Leif 

×
×
  • Create New...