My current job has strict security measures (referring to root access on a Linux server and the inability to access outside the company’s network), so it can be difficult in getting the tools necessary for my work, namely R packages on CRAN and Python packages via
On my Windows workstation, I was able to install R by downloading the installer online and Python via Cygwin. However, R and Python are unable to connect to the internet to download and install additional packages because of the company’s firewall. To get around this for R, I could:
- add the flag
--internet2to the execution path in R’s shortcut,
setInternet2(TRUE)in the R console, or
- set the environment variable
The first two tells R to use the proxy defined in Internet Explorer. I was able to access CRAN via my web browser, so this works. If CRAN is blocked on the browser, find out what proxy server is available at work and use that to access the outside world. If CRAN is also blocked on the proxy, put in a request to add it to the white list.
As for Python, install
pip and use a proxy to download and install packages:
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py --proxy="username:password@proxy_server:port" pip install --proxy="username:password@proxy_server:port" argparse numpy pandas ## etc
NOTE: pip 1.3.1 has issues with proxy servers, so use the latest version.
On a Linux/Unix server, the added complexity is that of a lack of root access. Typically, Python is available by default on any modern distro. If not, have the admin team install R and Python via the distribution’s package manager, and if they can’t, then compile the two from source and install them locally. Once installed, use the same method as before for Python
pip, but with the
--user flag in order to install the packages locally in
pip command is at
~/.local/bin/pip). For R, set the environment variables
export http_proxy="http://proxy_server:port/" export http_proxy_user="username:password"
and install the libraries to
~/Rlib (add this to the library path via