0

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

sultan
  • 5,978
  • 14
  • 59
  • 103
  • Have you googled this? There seems to many similar questions (even on this site) that indicate that it is related to installing multiple versions of python modules using different install methods. – Roger Lindsjö Nov 19 '11 at 10:07
  • Yes I've googled this. I want use of version 2.7.2 and so far I've been looking the ways of removing version 2.6 – sultan Nov 19 '11 at 10:43
  • 1
    Sorry about the "answer", meant to post it as a comment. I have seen posts where removing /System/​Library/​Frameworks/​Python.framework/​Versions/​2.6/​Extras/​lib/​python/​pkg_resources.pyc solved the warning, but am not sure how that affects the original version of python in OSX. – Roger Lindsjö Nov 19 '11 at 11:57
  • THANKS @Roger Lindsjö this worked for me, since I removed the file above I will test it this way some time if the same problem appears again – sultan Nov 19 '11 at 12:09
  • No! Do not remove files from `/System/Library`! See my answer below. – Ned Deily Nov 19 '11 at 18:57

1 Answers1

1

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.

Community
  • 1
  • 1
Ned Deily
  • 83,389
  • 16
  • 128
  • 151