一半君的总结纸

听话只听一半君

没root的破烂centos 6.4还是tcsh怎么装virtualenv

公司是古老的centos 6.4, csh,我还没root,造成virtualenvwrapper 用不了, virtualenvwrapper-csh也用不了,大概改几行就行,我不想学csh …

我准备把我的virtual env 都放 ~/Env下面

脑残法:

  1. 先装 virtualenv , 没有virutalenv wrapper我大不了手动….
    # 我装到~/.local因为没root
    pip install virtualenv --user
    
  2. 这时候如果你virutalenv myEnv会看到错误
    > virtualenv myEnv
    New python executable in myEnv/bin/python2
    Also creating executable in myEnv/bin/python
    Installing setuptools, pip...
      Complete output from command /home/fucker/Envs/myEnv/bin/python2 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
      Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named pip
    ----------------------------------------
    ...Installing setuptools, pip...done.
    Traceback (most recent call last):
      File "/home/fucker/.local/bin/virtualenv", line 9, in <module>
        load_entry_point('virtualenv==1.11.4', 'console_scripts', 'virtualenv')()
      File "/home/fucker/.local/lib/python2.6/site-packages/virtualenv.py", line 824, in main
        symlink=options.symlink)
      File "/home/fucker/.local/lib/python2.6/site-packages/virtualenv.py", line 992, in create_environment
        install_wheel(to_install, py_executable, search_dirs)
      File "/home/fucker/.local/lib/python2.6/site-packages/virtualenv.py", line 960, in install_wheel
        'PIP_NO_INDEX': '1'
      File "/home/fucker/.local/lib/python2.6/site-packages/virtualenv.py", line 902, in call_subprocess
        % (cmd_desc, proc.returncode))
    OSError: Command /home/fucker/Envs/myEnv/bin/python2 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
    

    不知道为啥,我版本已经是现在最新了

    > pip freeze | egrep "(pip|virtualenv|setuptools)" && python -c "import pip; print pip.__version__; import setuptools; print setuptools.__version__"
    virtualenv==1.11.4
    virtualenv-clone==0.2.4
    1.5.4
    3.4.4
    

    只好先这样

    virtualenv test --no-setuptools
    
  3. 然后自己装pip…
    wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py --no-check-certificate
    # -I表示ignore系统里已经装了的pip --prefix是说,装到myEnv的site-packages里去
    # python get-pip.py -I --install-option="--prefix=$HOME/Envs/myEnv/lib/python2.6/site-packages"
    # 其实不用来--prefix, 如果你先"激活"刚才的myEnv的话,所以
    source myEnv/bin/activate.csh
    python get-pip.py -I
    
  4. 然后就可以在这个 virtual env里装之前会和公司软件冲突的packages了,没有virtualenvmapper就麻烦点自己多敲几行…

    # 用之前先 activate
    source ~/Envs/myEnv/bin/activate.csh
    
    # 之后就是用这里的python了 \表示不要展开alias
    > which \python
    /home/fcuker/Envs/myEnv/bin/python
    
    > which pip
    /home/fucker/Envs/myEnv/bin/pip
    
    # 装个东西试试
    pip install requests
    

edit: 诡异的是,actiave之前,如果不cd任何一个目录,经常看到这错误

_OLD_VIRTUAL_PATH: Undefined variable.

这和virtualenvwrapper-csh提示的错误一样… 我猜virtualenvwrapper-csh也可以用了,用之前随便cd一个目录…

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: