Skip to content
Snippets Groups Projects

mypyR

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Dirk Sarpe

    make Installing and Configuring Python with RStudio work with our old workhorse

    mypyR.sh 3.22 KiB
    ds88bifa@rstudio1:~$ pip install virtualenv
    
      IOError: [Errno 2] No such file or directory: '/tmp/pip-build-mCEsJp/unknown/setup.py'
      
      ----------------------------------------
      Failed building wheel for unknown
      Running setup.py clean for unknown
      Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mCEsJp/unknown/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" clean --all:
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
      IOError: [Errno 2] No such file or directory: '/tmp/pip-build-mCEsJp/unknown/setup.py'
      
      ----------------------------------------
      Failed cleaning build dir for unknown
    Successfully built distlib filelock unknown unknown scandir
    Failed to build unknown
    Installing collected packages: six, distlib, contextlib2, unknown, scandir, pathlib2, unknown, importlib-metadata, appdirs, singledispatch, typing, importlib-resources, filelock, virtualenv
    Successfully installed appdirs contextlib2 distlib filelock importlib-metadata importlib-resources pathlib2 scandir singledispatch six-1.10.0 typing unknown unknown virtualenv-15.0.1
    You are using pip version 8.1.1, however version 20.0.2 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command
    # so virtualenv was installed but this is very old
    #
    # also
    ds88bifa@rstudio1:~$ which virtualenv
    /usr/bin/virtualenv
    ds88bifa@rstudio1:~$ pip install --upgrade pip
    Collecting pip
      Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
    Installing collected packages: pip
    Successfully installed pip-20.0.2
    # but we still need to use the correct pip because
    ds88bifa@rstudio1:~$ which pip
    /usr/bin/pip
    ds88bifa@rstudio1:~$ export PATH=~/.local/bin/:$PATH
    ds88bifa@rstudio1:~$ which pip
    /homes/ds88bifa/.local/bin//pip
    # just to be sure
    ds88bifa@rstudio1:~$ pip install virtualenv
    
    ds88bifa@rstudio1:~$ virtualenv --version
    virtualenv 20.0.15 from /homes/ds88bifa/.local/lib/python2.7/site-packages/virtualenv/__init__.pyc
    ########
    # ok step 2,3,4 from the instructions
    ds88bifa@rstudio1:~$ mkdir mypyR
    ds88bifa@rstudio1:~$ cd mypyR
    ds88bifa@rstudio1:~/mypyR$ virtualenv python
    created virtual environment …
    ds88bifa@rstudio1:~/mypyR$ source python/bin/activate
    (python) ds88bifa@rstudio1:~/mypyR$ 
    (python) ds88bifa@rstudio1:~/mypyR$ pip install numpy pandas matplotlib
    
    Successfully installed
    ########
    # ok step 5
    (python) ds88bifa@rstudio1:~/mypyR$ R
    
    > install.packages("reticulate")
    
    > quit("no")
    (python) ds88bifa@rstudio1:~/mypyR$ echo 'Sys.setenv(RETICULATE_PYTHON = "python/bin/python")' > .Rprofile
    (python) ds88bifa@rstudio1:~/mypyR$ R
    > reticulate::py_config()
    python:         /homes/ds88bifa/mypyR/python/bin/python
    libpython:      /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
    pythonhome:     //usr://usr
    virtualenv:     /homes/ds88bifa/mypyR/python/bin/activate_this.py
    version:        2.7.12 (default, Oct  8 2019, 14:14:10)  [GCC 5.4.0 20160609]
    numpy:          /homes/ds88bifa/mypyR/python/lib/python2.7/site-packages/numpy
    numpy_version:  1.16.6
    
    NOTE: Python version was forced by RETICULATE_PYTHON
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment