Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

OS: Ubuntu 14.04 LTS

Python: 2.7.6

My installation of Gourmet Recipe Manager suddenly stopped loading. When I run it in a terminal window, I get the following at the end of the traceback:

import datetime as dt
ImportError: No module named datetime

So far as I can tell, nothing has been changed and my Python installation is up to date. It simply quit working yesterday. I'd certainly appreciate a good approach to diagnose and fix this problem!

Update: thanks to all who replied!

Tim, I'm sorry if I asked this question in the wrong place. Please chalk it up to being a new guy simply following the links from the Ubuntu website.

TheSchwa, I tried your suggestion and got the same error message as above.

muru, the package seems to be installed, but I have no idea if it's installed/configured correctly. How might I find out?

I'm sorry for all the questions, but I'm an old RedHat guy who has been away from Linux for some time. All of the apt/dpkg stuff is new to me.

share|improve this question
    
While this is (just) on topic here, you might get a better response on Stack Overflow. Also, I can't reproduce it. No errors at all, on the same set-up as you... –  Tim Aug 10 at 7:44
    
What happens if you try import datetime in the python interpreter? You can start the interpreter by opening a terminal and executing python. You can leave it with Ctrl+d. –  TheSchwa Aug 10 at 7:58
    
According to dpkg -S $(python -c "import datetime; print datetime.__file__"), the datetime module is from the libpython2.7-stdlib package. Is that package correctly installed? Can you try reinstalling it? –  muru Aug 10 at 11:08
    
Okay, so the specific file is /usr/lib/python2.7/lib-dynload/datetime.x86_64-linux-gnu.so do you have that file? Also do you see /usr/lib/python2.7/lib-dynload listed in the output from echo $(python -c "import sys; print sys.path")? Btw the Stack Exchange system doesn't actually notify commenters when you edit your post; so at the very least always post a quick comment such as "Updated question with the info" so we get a notification telling us to check back :) –  TheSchwa Aug 12 at 1:04
    
Updated question with the info. Thanks, TheSchwa! My answers are no and yes, respectively. Now, where can I get a new copy of datetime.x86_64-linux.gnu.so? :) –  Joe Aug 12 at 4:03

4 Answers 4

This just happened to me after the 14.10 update, and it seems to be because my virtual environments have old copies of /usr/bin/python2.7 that — unlike the new binary — do not include datetime built-in, and so get an error when they cannot find it on disk anywhere. The new interpreter seems to import it without any file I/O (try running it under strace to check).

I fixed each virtual environment by activating it and running:

$ cp /usr/bin/python2.7 $(which python2.7)
share|improve this answer
1  
Gosh, thanks a bunch for this. –  Anto Dec 1 at 23:29

You can just reinitialize the virtualenv by:

cd <virtualenv-dir>
virtualenv .
share|improve this answer
1  
Note that it should be virtualenv . instead of virtualenv , –  icyrock.com Dec 12 at 14:41

As i found some changes in 14.04 so you need do this from root:

For datetime only:


ln -s /usr/lib/python2.7/lib-dynload/datetime.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/datetime.so

For all modules:


ln -s /usr/lib/python2.7/lib-dynload/audioop.x86_64-linux-gnu.so                       /usr/lib/python2.7/lib-dynload/audioop.so
ln -s /usr/lib/python2.7/lib-dynload/_bsddb.x86_64-linux-gnu.so                        /usr/lib/python2.7/lib-dynload/_bsddb.so
ln -s /usr/lib/python2.7/lib-dynload/bz2.x86_64-linux-gnu.so                           /usr/lib/python2.7/lib-dynload/bz2.so
ln -s /usr/lib/python2.7/lib-dynload/_codecs_cn.x86_64-linux-gnu.so                    /usr/lib/python2.7/lib-dynload/_codecs_cn.so
ln -s /usr/lib/python2.7/lib-dynload/_codecs_hk.x86_64-linux-gnu.so                    /usr/lib/python2.7/lib-dynload/_codecs_hk.so
ln -s /usr/lib/python2.7/lib-dynload/_codecs_iso2022.x86_64-linux-gnu.so               /usr/lib/python2.7/lib-dynload/_codecs_iso2022.so
ln -s /usr/lib/python2.7/lib-dynload/_codecs_jp.x86_64-linux-gnu.so                    /usr/lib/python2.7/lib-dynload/_codecs_jp.so
ln -s /usr/lib/python2.7/lib-dynload/_codecs_kr.x86_64-linux-gnu.so                    /usr/lib/python2.7/lib-dynload/_codecs_kr.so
ln -s /usr/lib/python2.7/lib-dynload/_codecs_tw.x86_64-linux-gnu.so                    /usr/lib/python2.7/lib-dynload/_codecs_tw.so
ln -s /usr/lib/python2.7/lib-dynload/crypt.x86_64-linux-gnu.so                         /usr/lib/python2.7/lib-dynload/crypt.so
ln -s /usr/lib/python2.7/lib-dynload/_csv.x86_64-linux-gnu.so                          /usr/lib/python2.7/lib-dynload/_csv.so
ln -s /usr/lib/python2.7/lib-dynload/_ctypes_test.x86_64-linux-gnu.so                  /usr/lib/python2.7/lib-dynload/_ctypes_test.so
ln -s /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so                       /usr/lib/python2.7/lib-dynload/_ctypes.so
ln -s /usr/lib/python2.7/lib-dynload/_curses_panel.x86_64-linux-gnu.so                 /usr/lib/python2.7/lib-dynload/_curses_panel.so
ln -s /usr/lib/python2.7/lib-dynload/_curses.x86_64-linux-gnu.so                       /usr/lib/python2.7/lib-dynload/_curses.so
ln -s /usr/lib/python2.7/lib-dynload/datetime.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/datetime.so
ln -s /usr/lib/python2.7/lib-dynload/dbm.x86_64-linux-gnu.so                           /usr/lib/python2.7/lib-dynload/dbm.so
ln -s /usr/lib/python2.7/lib-dynload/_elementtree.x86_64-linux-gnu.so                  /usr/lib/python2.7/lib-dynload/_elementtree.so
ln -s /usr/lib/python2.7/lib-dynload/fpectl.x86_64-linux-gnu.so                        /usr/lib/python2.7/lib-dynload/fpectl.so
ln -s /usr/lib/python2.7/lib-dynload/future_builtins.x86_64-linux-gnu.so               /usr/lib/python2.7/lib-dynload/future_builtins.so
ln -s /usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/_hashlib.so
ln -s /usr/lib/python2.7/lib-dynload/_hotshot.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/_hotshot.so
ln -s /usr/lib/python2.7/lib-dynload/_json.x86_64-linux-gnu.so                         /usr/lib/python2.7/lib-dynload/_json.so
ln -s /usr/lib/python2.7/lib-dynload/linuxaudiodev.x86_64-linux-gnu.so                 /usr/lib/python2.7/lib-dynload/linuxaudiodev.so
ln -s /usr/lib/python2.7/lib-dynload/_lsprof.x86_64-linux-gnu.so                       /usr/lib/python2.7/lib-dynload/_lsprof.so
ln -s /usr/lib/python2.7/lib-dynload/mmap.x86_64-linux-gnu.so                          /usr/lib/python2.7/lib-dynload/mmap.so
ln -s /usr/lib/python2.7/lib-dynload/_multibytecodec.x86_64-linux-gnu.so               /usr/lib/python2.7/lib-dynload/_multibytecodec.so
ln -s /usr/lib/python2.7/lib-dynload/_multiprocessing.x86_64-linux-gnu.so              /usr/lib/python2.7/lib-dynload/_multiprocessing.so
ln -s /usr/lib/python2.7/lib-dynload/nis.x86_64-linux-gnu.so                           /usr/lib/python2.7/lib-dynload/nis.so
ln -s /usr/lib/python2.7/lib-dynload/ossaudiodev.x86_64-linux-gnu.so                   /usr/lib/python2.7/lib-dynload/ossaudiodev.so
ln -s /usr/lib/python2.7/lib-dynload/parser.x86_64-linux-gnu.so                        /usr/lib/python2.7/lib-dynload/parser.so
ln -s /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so                       /usr/lib/python2.7/lib-dynload/pyexpat.so
ln -s /usr/lib/python2.7/lib-dynload/readline.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/readline.so
ln -s /usr/lib/python2.7/lib-dynload/resource.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/resource.so
ln -s /usr/lib/python2.7/lib-dynload/_sqlite3.x86_64-linux-gnu.so                      /usr/lib/python2.7/lib-dynload/_sqlite3.so
ln -s /usr/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so                          /usr/lib/python2.7/lib-dynload/_ssl.so
ln -s /usr/lib/python2.7/lib-dynload/termios.x86_64-linux-gnu.so                       /usr/lib/python2.7/lib-dynload/termios.so
ln -s /usr/lib/python2.7/lib-dynload/_testcapi.x86_64-linux-gnu.so                     /usr/lib/python2.7/lib-dynload/_testcapi.so

Also if you use virtual env copy

cp $(which python2.7) /opt/graphite/bin/python

to your env.

share|improve this answer
    
I upgraded to 14.04 and didn't need to do any symlink. Could you provide any evidence that messing the system libs like this is necessary and can't be avoided? –  Andrea Lazzarotto Sep 11 at 22:13

I got the error when I upgraded from Ubuntu 14.04 to 14.10. I recreated my virtualenv and the issue went away. So if you're working with a virtualenv, you should recreate it.

However if you don't, I suppose that reinstalling your project will work. Don't touch any system libraries! It can work for the time being, but will potentially lead to issues with others.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.