How do I set up a local python library directory / PYTHONPATH?

前端 未结 2 1272
感动是毒
感动是毒 2021-02-09 13:32

In the process of trying to write a Python script that uses PIL today, I discovered I don\'t seem have it on my local machine (OS X 10.5.8, default 2.5 Python install).

相关标签:
2条回答
  • 2021-02-09 13:57

    You are using the Apple-supplied Python 2.5 in OS X; it's a framework build and, by default, uses /Library/Python/2.5/site-packages as the location for installed packages, not /usr/local. Normally you shouldn't need to specify --prefix with an OS X framework build. Also beware that the setuptools (easy_install) supplied by Apple with OS X 10.5 is also rather old as is the version of Python itself.

    That said, installing PIL completely and correctly on OS X especially OS X 10.5 is not particularly simple. Search the archives or elsewhere for tips and/or binary packages. Particularly if you are planning to use other modules like MySQL or Django, my recommendation is to install everything (Python and PIL) using a package manager like MacPorts.

    0 讨论(0)
  • 2021-02-09 14:00

    Why did you specify --prefix in your easy_install invocation? Did you try just:

    sudo easy_install pil
    

    If you're only trying to install PIL to the default location, I would think easy_install could work out the correct path. (Clearly, /usr/local/python isn't it...)

    EDIT: Someone down-voted this answer, maybe because it was too terse . That's what I get for trying to post an answer from my cell phone, I guess. But the gist of it is perfectly valid, IMHO: if you're using --prefix to specify a custom install location with easy_install, you're kind of 'doing it wrong'. It might be possible to make this work, but the easy_install documentation has a section on custom installation locations that doesn't even mention this as a possibility, except as a small tweak to the virtual python option. I'd suggest following the OS X instructions if you want to install to a custom location on a Mac, --prefix just does not seem like the right tool for the job.

    0 讨论(0)
提交回复
热议问题