Domanda

I've successfulle installed Python 2.7.2.

I open terminal and see the following messages

/Library/Python/2.6/site-packages/virtualenvwrapper/hook_loader.py:16: UserWarning: Module pkg_resources was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.pyc, but /Library/Python/2.6/site-packages is being added to sys.path
  import pkg_resources
/Library/Python/2.6/site-packages/virtualenvwrapper/hook_loader.py:16: UserWarning: Module site was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site.pyc, but /Library/Python/2.6/site-packages is being added to sys.path
  import pkg_resources

How to fix this?

Sultan

È stato utile?

Soluzione

In general, you should never remove anything in /System/Library. That directory and the files in it are supplied by Apple as part of OS X. You risk breaking your system by doing so. Deleting /System/​Library/​Frameworks/​Python.framework/​Versions/​2.6/​Extras/​lib/​pyth‌​on/​pkg_resources.pyc isn't the end of the world but it is not a solution. Just because you installed a Python 2.7, you should not attempt to remove the Apple-supplied Python 2.6. I'm not sure I understand what you are trying to do but I'm guessing you had a 2.6 virtual environment and now want to create one using 2.7. If so, you should install a version of virtualenv for that new Python 2.7 and you need to create a new virtual environment using it. Don't use an existing virtualenv associated with the Python 2.6 instance. And do not use the easy_install commands in /usr/bin which are associated with the Apple-supplied Pythons. You should ensure your shell path is set up so that the Python 2.7 framework bin directory comes first on your PATH; the python.org installers will attempt to do that for you. You should see something like this:

$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

You can then use that Python to install virtualenv or pip or distribute.

BTW, the warning messages are due to the fact that you were using the system Python which comes with a version of setuptools installed but virtualenv also installs its own version. See Why does installing a python package break setuptools and causes pkg_resources to not be found? for a similar problem and a way to work around it using the system Python. Another solution is to not use the system Python with virtualenv.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top