Possible conflicting python installations

后端 未结 2 2063
庸人自扰
庸人自扰 2020-12-10 12:40

I\'m not sure if the default python installation is the one that I\'ve been installing modules to, and if that may be the cause of a conflicting Unicode byte size compatibil

相关标签:
2条回答
  • 2020-12-10 13:08

    What OS are you on? This is more a question for superuser, but try something like this. Ditch easy_install and use pip if you haven't already.

    On Ubuntu:

    sudo apt-get install python-setuptools 
    sudo easy_install pip 
    pip install --user numpy
    
    0 讨论(0)
  • 2020-12-10 13:31

    The problem indeed seems to be a mismatch of Python and Numpy compile settings.

    /usr/local/bin is where custom Python is installed, you should try to run using /usr/bin/python instead.

    Another solution is to use a virtualenv. Try this:

    virtualenv myproject
    cd myproject
    source bin/activate
    pip install numpy
    

    Basically virtualenv sets up a different Python installation with its own packages in the "myproject" directory. Running the "activate" command tells the system that you want to use this installation instead of the default system. This lets you have a different Python environment for different projects. Using virtualenv, each project can have its own versions of Python packages even if they're incompatible with other projects or system packages.

    Note you will have to repeat the "source" command each time you open a new shell and want to use that virtual environment. Also you might have to install the virtualenv command by using your OS package manager. If this isn't possible (e.g. you don't have root access) or your OS version is too old for some reason, you can also download it manually from https://pypi.python.org/packages/source/v/virtualenv/

    If you do ls -l /usr/local/bin/python* you should see that python and python2 are actually symlinks to python2.7, and likewise python-config and python2-config are symlinks to python2.7-config.

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