最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

artificial intelligence - Is it possible to include Ollama directly in my Python project? - Stack Overflow

programmeradmin4浏览0评论

I'd like to create a Python program with Ollama (llama3.2, or 3.3) included in my package, so that the user doesn't need to install it separately when installing my program.

I've done it with Tesseract-OCR, but it doesn't seem to work there...

Anyone knows if it is possible and how to do it?

I've tried adding a folder containing all the Ollama files and dependencies, as you would for a Windows installation, to my Python project.

I've done the same with Tesseract and it works with Tesseract OCR.

I'd like to create a Python program with Ollama (llama3.2, or 3.3) included in my package, so that the user doesn't need to install it separately when installing my program.

I've done it with Tesseract-OCR, but it doesn't seem to work there...

Anyone knows if it is possible and how to do it?

I've tried adding a folder containing all the Ollama files and dependencies, as you would for a Windows installation, to my Python project.

I've done the same with Tesseract and it works with Tesseract OCR.

Share Improve this question edited 6 hours ago desertnaut 60.4k32 gold badges152 silver badges178 bronze badges asked 7 hours ago alex_pythooonalex_pythooon 11 New contributor alex_pythooon is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 4
  • 2 Boo, hiss -- speaking as someone who's been Linux distro staff more than once, don't do this: It'll make downstream packagers rightly angry with you. Vendoring dependencies means that if a Linux distro has its own ollama package, updating that package when a security bug comes out isn't sufficient -- they now need to update the package for your software as well. It also bloats the distro (keeping two sets of ollama binaries!), and makes your program harder to package (can't rely on out-of-the-box Python-only tools; needs more build-time dependencies). – Charles Duffy Commented 4 hours ago
  • (This also makes trying to distribute distro-independent packages more difficult -- if you're bundling in binaries built to a specific distro's ABI in something you upload to pypi or the like, then your pypi package won't work on any distro that isn't ABI-compatible with the one you built on. Yes, this seems like a nice thing to do for your users, but if you're going to do it, do it in addition to conventional source-only packages that don't try to vendor dependencies; don't do it in place of conventional packaging). – Charles Duffy Commented 4 hours ago
  • Thank you @CharlesDuffy for your answer and your advice! So this is not destinated to the Linux distros but for Windows. I would like to make 2 installer for Windows, one without Ollama and one with it. Do you still think it is a bad idea? The reason why I want to do that, it is because I think that most of the users won't know and be able to install Ollama. I thought about this problem with Linux, but I haven't started to make an installer for Linux and I actually never did one. I am going to use this tutorial to do it : – alex_pythooon Commented 36 mins ago
  • @CharlesDuffy ubuntu/tutorials/create-your-first-snap#1-overview What do you think about it? By the way, if you need more context for my project, here you can check my project : github/PitarchAlexandre/pdf-summariser Some of the things that I wanted to improve are already improved, but it is not already merged – alex_pythooon Commented 34 mins ago
Add a comment  | 

2 Answers 2

Reset to default 1

Yeah I know how it feels like - I've gone through this before.

Essentially, ollama is written in Go (https://github/ollama/ollama) , so you'll have to figure out a workaround for this case.

I'd recommend distributing your application as a Docker container so that you can like preinstall Docker and also python using your image, and users get everything without separate installations as you wanted.

However, for a python package, you may also consider bundling together the ollama installer, you know, and write your own scripts for launching and managing the ollama server, but this can get tricky.

Yes, It's possible to bundle ollama with your Python package. It's more complex than tessracth tho.

You should use docker as it's the best approach here for cross platform working. You can package Ollama with Llama3 and your python.

  • Use Ollama image,
  • Pull the llama3,
  • Install python and dependecies,
  • Copy your app into the container,
  • EXPOSE ollama's default port,
  • Finally start ollama as a background process and run your python app.
发布评论

评论列表(0)

  1. 暂无评论