Python: select one of multiple installed module versions

后端 未结 4 1378
旧巷少年郎
旧巷少年郎 2020-12-05 04:41

On my system, I have several modules installed multiple times. To give an example, numpy 1.6.1 is installed in the standard path at /usr/lib/python2.7/dis

4条回答
  •  粉色の甜心
    2020-12-05 05:25

    I had this problem on a Mac I was using without administrator access. My solution was the following:

    1. Find the directory of the numpy version you want to use. For me this was /Library/Python/2.7/site-packages

    2. Create a file ~/.startup.py and point to it with PYTHONSTARTUP=~/.startup.py in your .bashrc file

    3. In .startup.py:

    import sys

    sys.path.insert(0,'/Library/Python/2.7/site-packages/') <--- imports this BEFORE the standard parts

    import numpy

    print("Importing numpy version"+numpy.__version__) <---- To remind that we have changed the numpy version

    This seems to work fine for me. I hope it helps.

提交回复
热议问题