Python Pythonpath Modules install

前端 未结 3 924
借酒劲吻你
借酒劲吻你 2020-12-18 08:41

I am kind of annoyed by the installation of modules in python and had a lot of trouble with it, so it would be fantastic to find a good solution for it. Here are my issues:<

相关标签:
3条回答
  • 2020-12-18 09:15

    The -d argument to easy_install tells it where to install the module(s).

    0 讨论(0)
  • 2020-12-18 09:18

    Based on the path (/Library/Frameworks/Python.framework/Versions/2.6) in your question, you appear to have installed an additional Python besides the ones supplied by Apple. That's the standard installation path for the python.org OS X installer.

    The trick to getting easy_install to install to the right Python site-packages location is to understand that each Python instance you have needs to have its own copy of easy_install and you need to make sure you are using the right one when you install a package. For OS X 10.5 and 10.6, Apple supplies easy_install commands in /usr/bin for the Pythons it supplies. For example, in 10.6:

    $ ls -l /usr/bin/easy_install*
    -rwxr-xr-x  2 root  wheel  925 Jun 30  2009 /usr/bin/easy_install*
    -rwxr-xr-x  1 root  wheel  421 Jun 30  2009 /usr/bin/easy_install-2.5*
    -rwxr-xr-x  1 root  wheel  421 Jun 30  2009 /usr/bin/easy_install-2.6*
    

    They will install into the appropriate locations in /Library/Python/2.x/ which is where the Apple-supplied Pythons look for site-packages by default.

    For a python.org Python, the default site-package locations are in /Library/Frameworks/Python.framework/Versions/x.y. Under the appropriate directory there is a lib/pythonx.y/site-packages as you found and also a bin directory. To make the Python there the default, make sure that that bin directory is on your shell PATH and comes before /usr/bin/, so something like:

    export PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}"
    

    The python.org installers by default try to modify your shell profile files, like .bash_profile, to do this. Then follow the instructions to install either setuptools, which supplies the traditional version of easy_install, or Distribute, the more cutting-edge version of easy_install. You should then see aneasy_install command in the framework bin directory:

    $ cd /Library/Frameworks/Python.framework/Versions/2.6
    $ ls -l bin/easy_install*
    -rwxr-xr-x  1 nad  admin  360 Aug 25 07:30 bin/easy_install*
    -rwxr-xr-x  1 nad  admin  368 Aug 25 07:30 bin/easy_install-2.6*
    

    and, if you use it to install packages, they will end up in the right place and everything will be happy.

    0 讨论(0)
  • 2020-12-18 09:20

    sudo env ARCHFLAGS="-arch x86_64" easy_install-2.7 lxml worked on Mac OS 10.9. Make sure to qualify the version of python you are using in the easy_install command.

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