-2

I'm new to Python and also new to Linux. I want to know why this code doesn't work?

(gmapenv)teruun@ubuntu:~/gmapenv$ python -c 'import googlemaps'
(gmapenv)teruun@ubuntu:~/gmapenv$ from googlemaps import GoogleMaps

and it says:

from: can't read /var/mail/googlemaps

what does this mean? what does from: can't read mean?

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
  • 4
    The first line apparently works. With the second line you are trying to execute Python code in bash, which naturally fails. ``from`` in bash has nothing to do with ``from`` in Python. – fjarri Sep 22 '13 at 13:22

1 Answers1

0

You need to install whatever Python libraries using e.g. pip or easy_install before you can import the googlemaps module in your Python code. This is because there is no GoogleMaps library that is built in to the Python standard library. I see you've already gotten started with using virtualenv, which is good. Also, perhaps you already installed a library, but maybe you installed the wrong one, or you installed it globally and then created a virtualenv, which by default is isolated from your globally installed packages. So either create a non-isolated virtualenv (not recommended) or install the package into the virtualenv (and uninstall globally).

Also, the second line you posted attempts to execute Python code directly on Bash, which doesn't work for obvious reasons, and gives a cryptic error message because Bash thinks you're expecting it to be a Bash command, and it just so happens that from actually is a command.

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
  • Thanks for helping. And I did as you said. But it's still going wrong. Here is what I typed and the error messages. I just can't get what's going wrong.(gmapenv)teruun@ubuntu:~/gmapenv$ pip install googlemaps Requirement already satisfied (use --upgrade to upgrade): googlemaps in ./lib/python2.7/site-packages Cleaning up... (gmapenv)teruun@ubuntu:~/gmapenv$ python -c 'import googlemaps' (gmapenv)teruun@ubuntu:~/gmapenv$ python search1.py Traceback (most recent call last): File "search1.py", line 5, in print GoogleMaps().address_to_latlng(address) – user2804234 Sep 22 '13 at 13:35
  • Code in the search1.py is this – user2804234 Sep 22 '13 at 13:37
  • #!/usr/bin/env python # Foundations of Python Network Programming from googlemaps import GoogleMaps address = '207 N. Defiance St, Archbold, OH' print GoogleMaps().address_to_latlng(address) – user2804234 Sep 22 '13 at 13:38
  • So your `ImportError` was fixed, I can see. If you have further problems which you feel you cannot solve on your own, feel free to open another question perhaps. Also, if my answer solved the problem you mentioned in the question, feel free to mark it as accepted. – Erik Kaplun Sep 22 '13 at 14:24
  • P.S. it's quite terrible to have to read multi-line console output snippets in comments, especially if you've cut off the most important part of the traceback, the error message. – Erik Kaplun Sep 22 '13 at 14:24
  • No,it's not solved. But still thanks for helping. I created a new enviorenment and installed the library but it still doesn't work. And my english is not so good to express well. – user2804234 Sep 22 '13 at 15:23
  • And can I get your email address and send the picture for you ? – user2804234 Sep 22 '13 at 15:26
  • Please just read a Python tutorial/book first. I'm sure with basic Python skill, you can solve your basic problems independently. – Erik Kaplun Sep 22 '13 at 21:54