5

Ruby/Nodejs解释器版本依赖笔记

 2 years ago
source link: http://wwj718.github.io/post/%E5%B7%A5%E5%85%B7/language-version/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

最近在折腾一个项目,对Ruby/Nodejs的版本有要求

  • ruby –version // ruby 2.2.3
  • node –version // v0.12.4
  • npm –version // 2.10.1

Ubuntu14.04

采用RVM来管理Ruby版本,当然也可以使用rbenv

Ubuntu

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source /home/ubuntu/.rvm/scripts/rvm
rvm install 2.2.3
rvm use 2.2.3 --default

Nodejs

update nodejs

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

采用NVM来管理Nodejs版本

使用n更方便(npm install -g n)

###Ubuntu

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
nvm install 0.12.4

brew install nvm

fish使用:https://github.com/Alex7Kom/nvm-fish

nvm install v4.2 nvm use V4.2

Python

pyenv

pyenv

  • brew install pyenv
  • pyenv install 2.7.11

在fish下需要在 .config/fish/config.fish添加:

:::text
setenv PATH "$HOME/.pyenv/bin" $PATH
eval (pyenv init - fish)

ps:我的vim比较奇怪,需要在system版本的python下才正常,有时为了用ssl需要2.7.10以上的版本的python,所以策略是采用pyenv local 2.7.11,临时变更版本

MacOS

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.7.5

linux

env PYTHON_CONFIGURE_OPTS="--enab-shared" pyenv install 3.7.5

我们顺便也把python的依赖记录下,一般来说,python一般版本只区分2/3,所以直接用系统包管理来装就行,注意区分pip2/pip3就好

virtualenv

使用-p参数指定python版本

virtualenv -p /usr/local/bin/python3 testenv3

ubuntu下安装

参考pyenv-installer,最后需要:source ~/.bashrc

如果遇到requests的ssl问题,建议使用python2.7.11或以上

python -c 'import ssl; print(ssl.OPENSSL_VERSION)’
# OpenSSL 1.0.2h  3 May 2016  才正常

sqlite3

参考关于 ImportError: No module named _sqlite3 报错解决方法

github/pyenv/pyrnv/wiki


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK