# \[Solved\] Can't upload any file to library: \[ERROR\] 'module' object has no attribute 'open'

**URL:** <https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67>\
**Category:** Get Help\
**Created:** [December 11, 2017, 2:43pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67 "2017-12-11T14:43:34Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 11, 2017, 2:43pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/1 "2017-12-11T14:43:34Z")

</div>

The system has been up and running for a long time without any problem, suddenly today I started having problems uploading files, mp3 or ogg. (I didn’t test other formats)  
Airtime analyzer complains with:

```
2017-12-11 15:38:06,670 [analyzer_pipeline] [ERROR] 'module' object has no attribute 'open'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/airtime_analyzer-0.1-py2.7.egg/airtime_analyzer/analyzer_pipeline.py", line 70, in run_analysis
    metadata = MetadataAnalyzer.analyze(audio_file_path, metadata)
  File "/usr/local/lib/python2.7/dist-packages/airtime_analyzer-0.1-py2.7.egg/airtime_analyzer/metadata_analyzer.py", line 44, in analyze
    ms = magic.open(magic.MIME_TYPE)
AttributeError: 'module' object has no attribute 'open'
2017-12-11 15:38:06,679 [message_listener] [ERROR] Analyzer pipeline exception: 'module' object has no attribute 'open'
2017-12-11 15:38:06,920 [status_reporter] [INFO] HTTP request sent successfully.
```

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [December 11, 2017, 3:01pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/2 "2017-12-11T15:01:28Z")

</div>

Weird. Off the top of my head, I’d search the github for term magic as I know we did some stuff with that.  
I assume you didn’t change anything and it just started to not work. Did you do an system update or anything that might of triggered this ?

I figure you tried restarting analyzer ?

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [December 11, 2017, 5:33pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/3 "2017-12-11T17:33:18Z")

</div>

Ok so according to this commit - [https://github.com/LibreTime/libretime/commit/9ce611130cef733251da72467314bffc5922ee15](https://github.com/LibreTime/libretime/commit/9ce611130cef733251da72467314bffc5922ee15) we are not using python magic anymore and instead are using file magic.

A little googling found this as well - [https://stackoverflow.com/questions/18226536/python-magic-module-object-has-no-attribute-open#18228897](https://stackoverflow.com/questions/18226536/python-magic-module-object-has-no-attribute-open#18228897)

So something happened, any idea if you might have done anything that could of caused this ?

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 11, 2017, 5:34pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/4 "2017-12-11T17:34:01Z")

</div>

No system update nor change since last successful uploads, it just stopped working, so weird

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [December 11, 2017, 5:44pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/5 "2017-12-11T17:44:44Z")

</div>

Hmm, make sure you have file.magic vs. python magic or possibly revert that code commit I linked too, because it should be using file.open only if you have file.magic. I’m not heavily versed in the python side of things but I can see this is what is causing it. Now what changed to make this happen is the bigger mystery.

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 11, 2017, 5:51pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/6 "2017-12-11T17:51:19Z")

</div>

Reverting to the old code and restarting airtime\_analyzer does nothing, it does neither fire any exception, I could not install file-magic because I cannot find any package named file-magic.

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [December 11, 2017, 6:14pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/7 "2017-12-11T18:14:53Z")

</div>

Did you try to do it with pip  
sudo pip install file-magic

It isn’t a system package.

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 12, 2017, 8:49am UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/8 "2017-12-12T08:49:03Z")

</div>

> [@robbt](#):
>
> sudo pip install file-magic

`sudo pip install file-magic`  
Requirement already satisfied: file-magic in /usr/local/lib/python2.7/dist-packages/file\_magic-0.3.0-py2.7.egg

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 12, 2017, 8:50am UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/9 "2017-12-12T08:50:53Z")

</div>

I did it! apparently there was a problem with debian’s package python-magic. This is what I did:

```
apt-get remove python-magic
sudo pip uninstall python-magic
sudo pip uninstall file-magic
sudo pip install file-magic
service airtime_analyzer restart

```

and now ms.open works, no need to use the old code!

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [December 12, 2017, 5:23pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/10 "2017-12-12T17:23:36Z")

</div>

Unrelated but you are using Debian and your able to import mp3 files correct ? I have a 9.2 install and all mp3 files file to import and liquidsoap gives segmentation faults. I’m trying to figure out what the cause is because I’m pretty sure some Debian installs are working for people.

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [December 12, 2017, 5:26pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/11 "2017-12-12T17:26:31Z")

</div>

Based upon github I’m presuming your using liquidsoap 1.3 self-installed.

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 19, 2017, 11:29am UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/12 "2017-12-19T11:29:16Z")

</div>

I just installed a new instance of Libretime 3.0.0-alpha.3 on a Debian 9 server, I could not successfully start liquidsoap yet, but as soon as I can I will let you know if I can or not upload mp3 files.

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [December 20, 2017, 8:58pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/13 "2017-12-20T20:58:35Z")

</div>

I can confirm that I can upload mp3 as well as ogg files in my recently installed Debian server with Libretime alpa.3. I just had to install some missing liquidsoap plugins after running the installer and that was it… everything seems to work as expected.

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [February 6, 2018, 5:26pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/14 "2018-02-06T17:26:41Z")

</div>

The issue happened again and no changes were made to the system. Not intentional at least. At 17:22 people was uploading files without any problem. At 17:38 the problem started to happen and users were not able to upload more tracks. During the period no changes or updates to the system. I am supposed to be the only administrator with root access and did not any installation or update whatsoever. Actually I was not even connected to the server. Is there something that might be installing python-magic ? which is the cause of the problem?

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [February 7, 2018, 9:31pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/15 "2018-02-07T21:31:42Z")

</div>

Hmm, weird. Is it possible that airtime-analyzer just crashed and needed to be restarted ? Or is it basically all imports are failing with liquidsoap and the python magic showing up again. If we can figure out the sequence of events we should open up a issue on github and try to get to the bottom of this.

---

<div class="post-metadata">

**Author:** ![JohnnyC1951](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/johnnyc1951/32/605_2.png) [@JohnnyC1951](https://discourse.libretime.org/u/JohnnyC1951)\
**Post date:** [February 27, 2018, 6:28am UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/16 "2018-02-27T06:28:34Z")

</div>

Ubuntu Trusty - LT 3.0.0-alpha.4. I also started getting exactly the same a week ago. I found this thread, did some digging with helpful pointers from above, and found that python-magic was somehow not installed. I installed it with a std. apt-get, restarted airtime analyzer and it sprang into life. I had been playing with eyeD3 (also Python) so maybe that uninstalled it? No idea, really, but the timing does seem to be suspicious with regard to other reports, but if it reoccurs I will try reinstalling and ‘holding’ it.

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [June 9, 2018, 10:46pm UTC](https://discourse.libretime.org/t/solved-cant-upload-any-file-to-library-error-module-object-has-no-attribute-open/67/18 "2018-06-09T22:46:29Z")

</div>

Definetly, eyeD3 needs python-magic to work properly. When you installed the package it was automatically installed. I had the same problem as I use eyeD3 and it complains about the missing python-magic.
