<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Prathamesh Desai</title>
    <description>The latest articles on Forem by Prathamesh Desai (@ozer619).</description>
    <link>https://forem.com/ozer619</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F717849%2F4c7500c1-54bf-4ce4-9eef-3cae2f69e9e2.jpeg</url>
      <title>Forem: Prathamesh Desai</title>
      <link>https://forem.com/ozer619</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ozer619"/>
    <language>en</language>
    <item>
      <title>Autojump </title>
      <dc:creator>Prathamesh Desai</dc:creator>
      <pubDate>Sat, 01 Jan 2022 08:04:39 +0000</pubDate>
      <link>https://forem.com/ozer619/autojump-4p26</link>
      <guid>https://forem.com/ozer619/autojump-4p26</guid>
      <description>&lt;p&gt;autojump is a command line utility similar to cd. It helps speeds up file navigation by maintaining a history of directories that have been previously navigated by the user. If there are directories with the same name, autojump maintains a weighted history to favor the most frequently accessed directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linode.com/docs/guides/faster-file-navigation-with-autojump/"&gt;complete guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;cheat sheet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;check weight
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;j -s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;autojump help
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;j --help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;jump to a directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;j foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;jump to a child directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jc bar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-The o command opens the file manager&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jo foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Managing multiple versions of Python using pyenv and virtualenvwrapper</title>
      <dc:creator>Prathamesh Desai</dc:creator>
      <pubDate>Fri, 05 Nov 2021 16:50:28 +0000</pubDate>
      <link>https://forem.com/mhf/managing-multiple-versions-of-python-using-pyenv-and-virtualenvwrapper-383h</link>
      <guid>https://forem.com/mhf/managing-multiple-versions-of-python-using-pyenv-and-virtualenvwrapper-383h</guid>
      <description>&lt;p&gt;Are you scared to use multiple versions of Python on your system? Don't worry this article will guide you towards the ultimate Python setup on Ubuntu.&lt;/p&gt;

&lt;p&gt;Sometimes we need to work simultaneously on multiple different projects which require different versions of Python and upgrading one Python version may break another project. It's also very hard to manage package installations manually respective to each Python environment and to switch between them. This is where pyenv comes into play to make your life easier.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is pyenv anyway?
&lt;/h4&gt;

&lt;p&gt;The pyenv Readme describes it best:&lt;/p&gt;

&lt;p&gt;pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well. It makes managing different versions of Python very easy and user friendly.&lt;/p&gt;

&lt;h4&gt;
  
  
  How do I install it on Ubuntu?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Let's update our local package index first:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install most common Python interpreter and compile dependencies:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install aria2 build-essential curl git libbz2-dev libffi-dev liblzma-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev llvm make tk-dev wget xz-utils zlib1g-dev --yes;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install pyenv:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install pyenv's virtualenvwrapper plugin:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git "${HOME}/.pyenv/plugins/pyenv-virtualenvwrapper"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Initialize and configure pyenv in your .bashrc file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#### pyenv config
if [ -f "$HOME/.pyenv/bin/pyenv" ] &amp;amp;&amp;amp; ! type -P pyenv &amp;amp;&amp;gt;/dev/null ; then
  export PYTHON_CONFIGURE_OPTS="--enable-shared"
  export CFLAGS="-O2"
  export PYTHON_BUILD_ARIA2_OPTS="-x 10 -k 1M"
  export PYENV_ROOT="${HOME}/.pyenv"
  export PATH="${PYENV_ROOT}/bin:${PATH}"
  eval "$(pyenv init --path)"
  eval "$(pyenv init -)"
  eval "$(pyenv virtualenv-init -)"
  if [[ ! "$(pyenv which python)" == "/usr/bin/python" ]] ; then
    pyenv virtualenvwrapper_lazy;
  fi
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Close and reopen the terminal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How do I install and use multiple versions of Python?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;To view Python versions available that pyenv can easily auto-download:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv install -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can check the current available and active versions of Python on your system by using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv versions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To install a new Python version:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv install &amp;lt;version&amp;gt;
Eg:- pyenv install 3.9.6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;I recommend that you activate all Python versions
that you have installed:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyenv global 3.10.0 3.9.6 3.8.11 3.7.11 3.6.14 2.7.18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: The order of versions we put in the above command matters as the first version will be the default version.&lt;br&gt;
In this case 3.10.0 will be the default version as it comes first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download virtual environment tools for each corresponding Python version:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3.9 -m pip install virtualenv virtualenvwrapper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Wait, but what is virtualenv and virtualenvwrapper?
&lt;/h4&gt;

&lt;p&gt;As explained by &lt;a href="https://www.bogotobogo.com/python/python_virtualenv_virtualenvwrapper.php"&gt;bogotobogo&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Virtual Environment enables us to keep the dependencies required by different projects in separate places, by creating virtual Python environments.&lt;/p&gt;

&lt;p&gt;In other words, virtualenv is a tool to create isolated Python environments. The virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, each project can have its own dependencies, regardless of what dependencies every other project has.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to use virtualenvwrapper?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Creating a virtual environment:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Creates a virtual env with default Python version
mkvirtualenv myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Creates a virtual env with specified Python version 3.8 for the below case:
mkvirtualenv -p python3.10 myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Mark the current directory as the virtualenv-linked Project Directory to automatically go to the Project Directory when activating it.
mkvirtualenv -p python3.10 -a $(pwd) myenv2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Deactivating the virtual env:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deactivate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start the virtualenv:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;workon &amp;lt;name of virtual env&amp;gt;
E.g workon myenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Credits
&lt;/h4&gt;

&lt;p&gt;This blog post is based on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An informal tutorial that &lt;a href="https://github.com/luzfcb"&gt;Fábio C. Barrionuevo da Luz&lt;/a&gt; gave me the other day in the Cookiecutter Discord. This blog post is just a glimpse of pyenv, virtualenv, virtualenvwrapper can do. A detailed and in-depth guide about these tools can be found &lt;a href="https://t.co/EwqifWLJH6?amp=1"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I am very thankful to Fabio and &lt;a href="https://github.com/audreyfeldroy"&gt;Audrey Roy Greenfeld&lt;/a&gt; for their patient and generous guidance. This article would not have been possible without them.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>ubuntu</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
