mdtraj库安装
Installation
官网推荐conda安装:
1
conda install -c conda-forge mdtraj
PIP安装:
1
pip install mdtraj
Windows环境python安装失败
不想装conda,直接
pip install mdtraj
报错:1
2
3
4
5
6
7
8
9
10
11
12
13
14Looking in indexes: http://pypi.douban.com/simple/
Collecting mdtraj
Downloading http://pypi.doubanio.com/packages/2f/03/c174bfb6471f796472ce1d8695f6c0d1a20ad6516cb789b70052df45b7a6/mdtraj-1.9.7.tar.gz (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 3.7 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [34 lines of output]
...
...
...直接源码安装:
1
2
3git clone https://github.com/mdtraj/mdtraj
cd mdtraj
pip install -e .- 跟上面直接
pip
报同样的错误
- 跟上面直接
在
mdtraj
文件夹下直接python .\setup.py install
出现了不同的错误:1
2
3
4
5
6
7
8
9
10
11
12
13...
...
...
cc.initialize()
File "D:\softwares\Python\Python311\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 253, in initialize
vc_env = _get_vc_env(plat_spec)
^^^^^^^^^^^^^^^^^^^^^^
File "D:\softwares\Python\Python311\Lib\site-packages\setuptools\msvc.py", line 214, in msvc14_get_vc_env
return _msvc14_get_vc_env(plat_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\softwares\Python\Python311\Lib\site-packages\setuptools\msvc.py", line 168, in _msvc14_get_vc_env
raise distutils.errors.DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/- 看样子需要安装:Microsoft C++ Build Tools
下载安装 Microsoft C++ Build Tools 后(默认安装),再次安装
1
python .\setup.py install
成功一部分,显示
Cython
包未安装:1
2
3
4
5
6
7
8
9C compiler:
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.35.32217.1 版
版权所有(C) Microsoft Corporation。保留所有权利。
用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]
Attempting to autodetect OpenMP support... Compiler supports OpenMP
mdtrajs setup depends on Cython (>=0.29). Install it prior invoking setup.py
No module named 'Cython'安装
Cython
包后再次安装1
2pip install cython
python .\setup.py install以为安装成功了,又报错:
1
2
3
4
5...
...
...
mdtraj/formats/tng/src/lib/tng_io.c(32): fatal error C1083: 无法打开包括文件: “zlib.h”: No such file or directory
error: command 'D:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2安装zlib:
1
git clone https://github.com/madler/zlib.git
不想装vs,太臃肿了,所以这里我不尝试了(有机会再试),还是用Linux版的吧
Ubuntu环境python安装
PIP安装成功:
1
pip install mdtraj
1
2
3
4
5
6
7
8
9
10
11
12
13
14Collecting mdtraj
Using cached mdtraj-1.9.7.tar.gz (2.1 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: scipy in /home/cup/.local/lib/python3.8/site-packages (from mdtraj) (1.7.3)
......
Building wheels for collected packages: mdtraj
Building wheel for mdtraj (PEP 517) ... done
Created wheel for mdtraj: filename=mdtraj-1.9.7-cp38-cp38-linux_x86_64.whl size=8473679 sha256=31b82b30935b14413c5d62fe126d29f8837dcc745bb46ba030902d8ba54facfc
Stored in directory: /home/cup/.cache/pip/wheels/68/ff/96/5d9a2efac5e5918e5c8fd799e8703e2f8b804a029bcbbd2431
Successfully built mdtraj
Installing collected packages: astunparse, mdtraj
Successfully installed astunparse-1.6.3 mdtraj-1.9.7
mdtraj测试
安装测试包
1
pip install pytest
测试
1
2
3
4git clone https://github.com/mdtraj/mdtraj.git
cd mdtraj
# If using conda, make sure to have your conda environment active
py.test