Как установить NumPy и Scipy для Python?

Скрипт run_scaled предоставляет следующую опцию:

--scale  Sets the factor the application is scaled by.
         Fractional scales are supported. It is set to 2 by default.

Чтобы изменить коэффициент масштабирования, вам нужно запустить скрипт на исполняемом файле, который вы хотите запустить с масштабированием, например,

/path/to/run_scaled --scale=1.2 /path/to/application

36
задан 15.05.2020, 00:05

1 ответ

Хорошо, давайте следуем руководству по установке :

  1. Там написано, что вам нужен Python 2.7 (который у вас уже есть):

    $ python --version
    Python 2.7.4
    
    [1121 ]
  2. Затем он говорит, что вам также нужен пакет NumPy, версия> = 1.4.1:

    apt-cache policy python-numpy
    python-numpy:
    Installed: (none)
    Candidate: 1:1.7.1-1ubuntu1
    Version table:
     1:1.7.1-1ubuntu1 0
        500 http://archive.ubuntu.com/ubuntu/ raring/main amd64 Packages

    Как вы видите, у меня есть версия NUMPY 1.7.1, так что давайте приступаем к его установке:

    sudo apt-get install python-numpy
    
  3. Теперь он говорит, что нам нужен Cython, давайте проверим, доступен ли этот пакет:

    apt-cache policy cython
    cython:
    Installed: (none)
    Candidate: 0.17.4-0ubuntu1
    Version table:
     0.17.4-0ubuntu1 0
        500 http://archive.ubuntu.com/ubuntu/ raring/main amd64 Packages

    У нас есть, мы установите его:

    sudo apt-get install cython
    

    Пожалуйста, обратите внимание, что существуют и другие пакеты с зависимостью, которые также устанавливаются.

  4. Как ни странно, нам также нужен модуль scipy:

    sudo apt-get install python-scipy
    
  5. Тестирование . Откройте python в терминале и введите следующее:

    $ python
    Python 2.7.4 (default, Sep 26 2013, 03:20:26) 
    [GCC 4.7.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy
    >>> import scipy
    >>> import cython
    >>> exit()
    

    Выше, должно быть без ошибок. Если что-то пошло не так, зайдите и прочитайте руководство снова, вы забыли / пропустили шаг.

  6. Скачивая источники CLASS со своей страницы, перейдите в каталог в терминале, распакуйте его и сделайте это:

    cd where/the/tar/is
    tar zxf class_v2.0.2.tar.gz
    cd class_v2.0.2
    make

    Здесь мы будем ждать до завершения. Как только это будет сделано, мы идем в каталог python и запускаем магию. Не переходя из каталогов, запустите это:

    cd python
    python setup.py build
    python setup.py install --user

    Теперь у нас установлен CLASS в нашем пользовательском каталоге. Мы должны это проверить!

    python
    Python 2.7.4 (default, Sep 26 2013, 03:20:26)
    [GCC 4.7.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from classy import Class
    >>> exit()
    

    Все здесь довольно уютно.

  7. Теперь время истины, загрузите taryball monthypython в вашу директорию кода:

    cd ~
    mkdir code
    cd code
    wget https://www.dropbox.com/s/l7mnhwsktp1m8b5/montepython_v1.2.5.tar.bz2?dl=1 -O montepython_v1.2.5.tar.bz2
    tar jxf montepython_v1.2.5.tar.bz2

    В инструкциях по установке есть некоторые заметки , которые не относятся к этому особому случаю. (новая установка), но это может быть важно при обновлении montepython.

  8. Это изменение важно. Вы помните, где вы установили КЛАСС? Теперь вы должны сказать Монте Пайтону, где это. В моем случае это /home/braiam/src/class_v2.0.2/class, ваш может отличаться. Вы можете использовать find, чтобы найти его:

    find ~ -name class -print
    

    Хорошо, теперь я изменяю файл default.conf, используя все, что вам нравится (я буду использовать nano) и изменяю путь root, поэтому полный файл будет выглядеть так:

    # Fill in the relevant path to your personal distribution. 
    # If you create a new file out of this one, please remember to call
    # MontePython.py with the option '-conf my.conf'
    
    # At minimum, this file should contain one line:
    # ** path['cosmo'] =  path to the cosmological code you are using. Note, if you are
    # using a modified version of class, be sure that the path contains the word
    # class, otherwise the code might not recognise it.
    
    # If you want to use a data folder different from the one present in the folder
    # you are executing the code, please also add:
    # ** path['data']  =  /path/to/the/other/data/
    
    root = '/home/braiam/src/class_v2.0.2/'
    
    path['cosmo']           = root+'/class/'
    

    Сохраните файл и выйдите.

  9. Тест монтепиона! Если все в порядке, вы можете запустить code/MontePython.py --help в своем каталоге montepythong, и все должно работать:

    ~/src/montepython$ code/MontePython.py --help
    usage: MontePython.py [-h] [-N number of steps] [-o output folder]
                      [-p input param file] [-c input cov matrix]
                      [-j jumping method] [-f jumping factor]
                      [-conf configuration file] [-chain_number chain number]
                      [-r restart from chain] [-bf restart from best fit file]
                      [-info [compute information of desired file [compute information of desired file ...]]]
                      [-bins desired number of bins, default is 20] [-no_mean]
                      [-comp comparison folder]
                      [-extra plot file for custom needs] [-noplot] [-all]
                      [-ext change extension for the output file]
                      [-fontsize desired fontsize, default is 15]
                      [-ticksize desired ticksize, default is 13]
    
    Monte Python, a Monte Carlo code in Python

    optional arguments: -h, --help show this help message and exit -N number of steps -o output folder -p input param file -c input cov matrix -j jumping method -f jumping factor -conf configuration file -chain_number chain number -r restart from chain -bf restart from best fit file -info [compute information of desired file [compute information of desired file ...]] -bins desired number of bins, default is 20 -no_mean -comp comparison folder -extra plot file for custom needs -noplot -all -ext change extension for the output file -fontsize desired fontsize, default is 15 -ticksize desired ticksize, default is 13

[1130]

С этим, у вас установлен montepython и он готов к работе!

41
ответ дан 15.05.2020, 00:05

Теги

Похожие вопросы