Jump to content

Python Modules Trouble


Forgiven
 Share

Recommended Posts

Hi folks. I have some funky stuff going on. I recently loaded some new modules, but they appear in a new and different path than my other modules.

To be clear I have a working set of python modules for scientific computing in /Users/myname/Library/Python/2.7/site-packages. The new modules I loaded using pip install sent them to /usr/local/lib/python2.7/site-packages. I want all of them in /Users/myname/Library/Python/2.7/site-packages. How can I move all the site-packages from the /usr...path to the /Users...path using the kind of command-line kung fu some of you know? AND make sure any future installs all go to my desired /Users...site-packages path?

OR: what is the cleanest way to uninstall all the stuff (delete) in /usr...site-packages path and force all the reinstall to the /Users..site-packages path? I didn't find the answers I need on StackOverflow. If you can help with script kiddie line-by-lines that would really lower my blood pressure. I'm a chemist not a coder :)

Thanks in advance.

Link to comment
Share on other sites

Python on a Mac... I've had my share of headaches with that.

You can just move/copy the pip installed modules to the other directory (Check the directories first in case some stuff might get overwritten).

cp -r /usr/local/lib/python2.7/site-packages/* /Users/myname/Library/Python/2.7/site-packages

or use rsync

rsync -azrv /usr/local/lib/python2.7/site-packages /Users/myname/Library/Python/2.7/

The advantage of rsync are that you won't overwrite exisiting files that are identical as they won't be copied. If the files differ however then they will be overwritten, so make sure there's no special version of a module in the user directory first.

The flags mean:

a - archive mode

r - recursive

v - verbose

z - compress during transfer (may not need that)

or just use `pip remove <package>` to delete them and re-install later.

To change the install path of the packages for pip use the -t, --target <dir> flag when you run the install

Unfortunately there doesn't seem to be a global config file for pip, so you'll have to add that flag each time.

Edited by Elk
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...