-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot Run Sarracenia due to Missing Magic #721
Comments
simplest is to install the dependency. A couple of methods: on ubuntu:
in a (non-ubuntu, but still normal) python environment:
(might be pip3, depending on installation.) but you're on windows... hmm... this brings up the whole python environment morass... Are you using Anaconda? how did you set this up? |
Neither This is being set up using Python 3.10 in a venv. |
sanity checking: you need to be in the venv when doing the pip... I guess you ran activate before pip? https://stackoverflow.com/questions/21240653/how-to-install-a-package-inside-virtualenv |
Yes, I created a fresh venv for this. activated the venv ran the install commands and got the above error. The same error was produced by the Docker instance. The same commands did not produce this error, or any error, in the past. |
To clarify, the Docker instance had a different missing module error, it's Ubuntu. Maybe running the above install commands in the GitHub Action will allow Sarracenia to work in the instance. I will try this tomorrow. This still doesn't cover the windows case, which would be nice to have, but not necessary if it works in Docker. |
In addition, even if this were to work, it is probably still important to have Sarracenia working on Windows machines too since many developers are using them. |
ooh... It isn't complaining about the python module, but the underlying C library that the python library calls. I thought that would have been in the base OS... ok... let me see: https://pypi.org/project/python-magic/ on windows it says you need to "pip install python-magic-bin" on ubuntu linux it needs:
I'm puzzled that a linux environment doesn't have that built-in, I would have expected it to be there by default. I'm doubly confused that installing the python package doesn't pull in the binary... you would think it would be a dependency. We're interested in your thinking about windows support. I've been working on keeping windows compatibility for the package, and every once in while we check, as >99% of usage is on linux, and several devs want to just provide a container (which is just a slimmed down linux) for people to use on windows, and not bother with a native binary. It would probably be easier to validate that... what do you think? |
I will try those adding those particular commands on Monday and see if the instances work. And I don't know where your stats are from although people from NRCan-RNCan use Windows. This should work on Windows. |
Also, how would the container work in terms of processing messages? Sarracenia moth is a Python library with functions that are distributed throughout the code where it's used. This would require significant reworking of existing code for an equivalent Sarracenia moth integration. |
for container: one would define a volume the container would look for plugins and configs, and the container would run using the configurable containers... there would be no change in the code. It's good to hear you were successfully using it on windows... we will put more effort on testing there. |
I don't understand, it sounds unnecessarily complicated. Why can't it just be a module you download and use? |
And when are you going to reintroduce Windows and Ubuntu support? |
To be clear: installing: installing: |
On your python install, did you try: "pip install python-magic-bin" ? does that work to get a working magic library? |
I tried that and it appears to be working now. Thank you for looking into this. |
actually wait, one second |
It works on Windows, although when I try to install it on Ubuntu, the install commands don't work! |
do not work in the Ubuntu Dockerfile |
Are you using a venv on ubuntu or just system packages?
|
I am not using venv inside the Docker instance, there is no purpose or need. I tried those commands, they did not work. |
a little more information please, do you have an error message? or is the dockerfile something we can see? |
This Dockerfile works with FROM ubuntu:latest
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
python3-pip \
python3-setuptools \
python3-wheel \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY ./app .
RUN pip3 install -r requirements.txt
RUN pip install metpx-sr3
RUN pip3 install metpx-sr3[amqp,mqtt,vip]
RUN pip3 install metpx-sr3
EXPOSE 5671
EXPOSE 5672
EXPOSE 15671
EXPOSE 15672
CMD [ "python3", "./__main__.py" ] |
so... in the list of packages installed via apt-get install you should be able to add the two others: python3-magic, and libmagic1 .... If you want to do it with a separate line... then: # after the apt update... an error message might be helpful. |
fwiw, the reason why it's broken is because I thought libmagic1 was included with every ubuntu... no need to explicitly include it. it's still weird not to be there, now that I know it's missing sometimes, I will add code to gracefully degrade... |
Just saw your message, I tried adding the command and it produced an error:
also found in the logs:
|
to the docker file, try adding a line: RUN pip3 install python-magic |
The Dockerfile worked with this command, although on run still the same missing module error:
|
okaay.... above the other RUN... add this: RUN apt install libmagic1 |
Produces the same error:
|
perhaps apt-get in place of apt ... again... should always be there, but perhaps stripped out in the name of minimalism. it's like the repo isn't configured, but when I look it's in main... so no ... weird. |
Okay got the message, I'll run the script tomorrow. |
Also added *all* extra to install all extras.
documenting recent changes (optional filetypes extra) and recent both languages.
Using |
I think the issue is that you are not rebuilding your docker image from scratch. I just built my own, with a copy/paste of your Dockerfile from a few posts up, inserted python3-magic into the main apt-get list... and it worked fine. I think you need some judicious use of docker rm and docker rmi, followed by docker build. (if you are using vanilla docker, ymmv for other environments.) |
Your assumption is incorrect, I am building with rm and nocache. Adding We now figured out how to run Sarracenia |
…s. (#735) * issue #721 make magic an extra, degrade gracefully when missing. Also added *all* extra to install all extras. * updating documentation for #721, new filetypes extra. documenting recent changes (optional filetypes extra) and recent both languages. * replace pip install of magic dep with debian one. * correcting syntax for all-dressed option
ok the work for #738 makes dependencies optional and obvious. So users should not have this problem. in future:
There were also more tests done on the self-extracting executable on windows, as well as an editable installation using a standard python installation and pip install -e. All of the above released in v3.00.43 |
Hi Peter,
I saw there were some updates related to Magic:
#698
When I run Sarracenia, it gives me an error that it cannot load Magic/libmagic:
I looked through the code and I see the loader attempts to search for the appropriate library.
What is the best way to get this module working again?
The text was updated successfully, but these errors were encountered: