Magic python lib isnt working.
I will attach the full build logs below
Solution:Jump to solution
nixpacks is being difficult, we are moving to a Dockerfile, add this as a Dockerfile to your project -
```dockerfile
FROM python:3.12
ENV PYTHONUNBUFFERED=1...
51 Replies
Project ID:
1b8eef65-7914-42b8-81ff-e5902b594bd8
1b8eef65-7914-42b8-81ff-e5902b594bd8
It does work on my local pc just not when deploying
I am also running the same python version on both railway and my pc
what version of python do you use locally?
Im using 3.12.0
nixpacks doesnt support python 3.12 yet, so instead add
3.11
to a runtime.txt fileOhhh, good to know
I just pushed with 3.11 now
I still get the same error
python-magic-bin 0.4.14 if from 2017
Is there a way to
apt-get
something?
Ill try without making it 0.4.14yeah, but may i ask why?
i would highly recommend using something pure python thats more up to date
On the python-magic github it says on Debian/Ubuntu to use
sudo apt-get install libmagic1
, i just didnt know if i could apt-get something on railway so i was trying to do it without using it
I couldtn find anything
because i had tried but there just wasnt anything up to date
I am using something from 7 years ago right now and it is just too outdated so I was hoping to get something a little newerthe
-bin
version would include libmagic1
im now thinking python-magic-bin is not compatible with python 3.8+I dont know if i even have a python version that old on my local pc
And it does work on my local pc
I will check again to make sure
Yeha it works on my pc
using python 3.12
its already installed, so of course it will work lol
Oh wait
im tired lmao
It does install on my localpc
its already installed
I just tried uninstalling
and installing agian with
--no-cache-dir
and it did workwhat os are you using?
Windows 10
so its obv a lot different then ubuntu but idk
might not support ubuntu
Im guessing not
but i did read that
python-magic
can be installed with apt-get install
on some random website
so would i be able to test that? or is that not doable?
Oh it seems like its for python 2.7 though so nevermind
Im not very good with linux so I dont knowuse this https://pypi.org/project/python-magic/
and then place this nixpacks.toml file in your project -
Okay let me give that a try
Im getting an Import error now,
build logs please
is this a web app of some kind?
Yeah
Im using the magic lib for a file uplaoder
flask? fastapi?
fastapi
why arent you using gunicorn?
I wish i had an answer lol
pretty much got lazy and im jsut debugging atm
I will swap to it though
Is gunicorn like way better than uvicorn?
I havent looked into that much at all to be honest
haha im tired too, i meant uvicorn
ohh
I just do it in my python code
Because of my debugging on my pc
it was jsut quicker to run it lol
so pretty much just because im lazy
the fastapi constructor is named app right?
Yeah
Heres how i start it
Would it be better to start it using the start command, or is this just fine?
Solution
nixpacks is being difficult, we are moving to a Dockerfile, add this as a Dockerfile to your project -
(you can delete the nixpacks.toml file)
Okay, ive never toucher dockerfiles so i dont knwo them well. What do i name the file? Just
Dockerfile
?correct
alright
as you can see, its just a set of commands that setup the project, super simple stuff
Yeah they seem pretty helpful
maybe ill look into them some more
not as finicky as nixpacks
It started
Let me test it out but it should work
The code ran so that seems like a good sign to me
Thank you!!
Ive been trying to figure that out for days now lol
no problem!
Have a good night!
Dockerfiles are always the answer
you too!!
Will use them in the future