0

So i downloaded the lastfm api for python made by people. found here: http://code.google.com/p/python-lastfm/

I have a website hosting through dreamhost. I wasnt able to build the module using:
python setup.py build
in my shell that i used putty to get into. But when i would run
python setup.py install
it would return an error. Figuring that all install really does is throw the files from the lib dir into the python site-packages folder, i decided to try and manually do it. I was successful in doing so on my local machine and was able to run python and type import lastfm with no errors. But i could not get it working on my webhost.

I do have quite the clusterfuck currently on my webhost due to my n00bism, by that i mean i tried installing python multiple times, and i dont really know where it installed successfully. All i know is i can go to putty and type python and it will run, but i dont know exactly where from. So i copied the lastfm build over to every python2.x/lib/site-packages i could find, but to no avail.

I dont know what im doing wrong. It says pythons os path is usr/lib/python2.5 and i figure usr means the root or local. idk. im very confused.

I also am curious because i am able to import things like mysql and sqlite by typing
import MySQLdb
import sqlite
import sqlite3

and all those work, yet i dont see them anywhere in my python path.

thanks in advance. if i need to list more info please tell me. thanks!

edit:

$ python setup.py install running install error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the installation directory:

[Errno 13] Permission denied: '/usr/lib/python2.5/site-packages/test-easy-install-11740.write-test'

The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was:

/usr/lib/python2.5/site-packages/

Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable.

For information on other options, you may wish to consult the documentation at:

http://peak.telecommunity.com/EasyInstall.html

Please make the appropriate changes for your system and try again.


that is the error i would get when i would try to do python setup.py install

stackVidec
  • 291
  • 1
  • 5
  • 8

3 Answers3

0

Python packages are searched in your PYTHONPATH. If you do echo $PYTHONPATH or

import sys
print sys.path

you will get a list of directories from where the modules are being imported. In your case with python-lastfm, you are installing using one version of Python and trying to run the program using another version. This is most often the case of confusion when you find that something is not getting imported. Use the full path of python /usr/bin/python2.6 or do a which python and try to use full path to build and install using setup script and try again.

Senthil Kumaran
  • 54,681
  • 14
  • 94
  • 131
  • Alright I was able to run the copy of python i wanted by stating the location of the python i wanted and then i got the import working. My question now then is what version of python was i running before? cause I would just type 'python' in any directory while in a shell and it would run a version of python. where is that one located? Im referring to me being connected to my webhosting and accessing it via a shell. – stackVidec Feb 25 '11 at 07:33
  • You can find that out of by typing `which python`. It might be `/usr/local/bin/python` pointing to a particular version. Note that in Unix PATH, the /usr/local/bin comes before /usr/bin giving preference to user installed versions before the system default ones. – Senthil Kumaran Feb 25 '11 at 08:23
  • sweet thanks for the help. one last thing if you can. when i type in which python it returns usr/bin/python which im ok with. But in that folder there is simply the python file and nothing else (minus pydoc and idle). So im guessing the locations of the modules and other stuff is located somewhere else. is there any easy way to find out where that would be? – stackVidec Feb 25 '11 at 09:32
  • Go to the interpreter. Import any module and try it `__file__` attribute. Like `import sys;sys.__file__` will show which file it is from. – Senthil Kumaran Feb 25 '11 at 16:51
  • alright excellent!!! thanks man i really appreciate it, i got everything working now. my webhost is located at /home/myusername/* and when i would call just python, it would call a version of python that they had installed that i don't have direct access to. Like its python installed before myusername directory. So now in my php file im just calling the version of python i have located at /home/myusername/build/Python-2.5/python and works like a charm. now ill just install all my modules manually there. excellent. thanks again it is greatly appreciated. – stackVidec Feb 25 '11 at 23:12
0

In some Linux-Distributions (Debian, Ubuntu) site-packages is not in PYTHONPATH. You could add it to your PYTHONPATH, place a link in dist-packages or add a path configuration file.

Documentation: Modifying Python’s Search Path

johnbaum
  • 664
  • 4
  • 5
0

Most of the time, to install python packages on any UNIX based system (linux/os x/bsd) you need to do:

sudo python setup.py install

This is, of course, if you have sudo rights.

gnur
  • 4,671
  • 2
  • 20
  • 33