Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django: Add ZSH info for setting up dev environment #4662

Merged
merged 4 commits into from May 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -129,9 +129,8 @@ <h3 id="Ubuntu_20.04">Ubuntu 20.04</h3>

<p>Ubuntu Linux 20.04 LTS includes Python 3.8.5 by default. You can confirm this by running the following command in the bash terminal:</p>

<pre class="brush: bash"><span style="line-height: 1.5;">python3 -V
Python 3.8.5</span>
</pre>
<pre class="brush: sh">python3 -V
Python 3.8.5</pre>
Ryuno-Ki marked this conversation as resolved.
Show resolved Hide resolved

<p>However, the Python Package Index tool (<em>pip3</em>) you'll need to install packages for Python 3 (including Django) is <strong>not</strong> available by default. You can install <em>pip3</em> in the bash terminal using:</p>

Expand All @@ -140,10 +139,10 @@ <h3 id="Ubuntu_20.04">Ubuntu 20.04</h3>

<h3 id="macOS">macOS</h3>

<p>macOS "El Capitan" and other more recent versions do not include Python 3. You can confirm this by running the following commands in the bash terminal:</p>
<p>macOS "El Capitan" and other more recent versions do not include Python 3. You can confirm this by running the following commands in the zsh or bash terminal:</p>

<pre class="brush: bash"><span style="line-height: 1.5;">python3 -V
</span>-bash: python3: command not found</pre>
<pre class="brush: bash">$ python3 -V
python3: command not found</pre>

<p>You can easily install Python 3 (along with the <em>pip3</em> tool) from<a href="https://www.python.org/"> python.org</a>:</p>

Expand All @@ -164,9 +163,8 @@ <h4>Note</h4>

<p>You can now confirm successful installation by checking for the <em>Python 3</em> version as shown below:</p>

<pre class="brush: bash"><span style="line-height: 1.5;">python3 -V
Python 3.9.0</span>
</pre>
<pre class="brush: bash">python3 -V
Python 3.9.0</pre>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.9.4 is the latest point release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I am not going to update this to latest version without re-testing the whole tutorial. I tend to do that once every 6- 12 months. So please ignore for now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me. Just wanted to highlight it. I'm wondering, if I were to do that today, whether I'd get the newer version (and thus, a note might be helpful to not confuse beginners).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will think on this, and perhaps address in the next update. I don't disagree.


<p>You can similarly check that <em>pip3</em> is installed by listing the available packages:</p>

Expand Down Expand Up @@ -194,14 +192,12 @@ <h4>Note</h4>

<p>You can then verify that Python 3 was installed by entering the following text into the command prompt:</p>

<pre class="brush: bash"><span style="line-height: 1.5;">py -3 -V
Python 3.8.6</span>
</pre>
<pre class="brush: bash">py -3 -V
Python 3.8.6</pre>

<p>The Windows installer incorporates <em>pip3</em> (the Python package manager) by default. You can list installed packages as shown:</p>

<pre class="brush: bash"><span style="line-height: 1.5;">pip3 list</span>
</pre>
<pre class="brush: bash">pip3 list</pre>

<div class="notecard note">
<h4>Note</h4>
Expand Down Expand Up @@ -262,7 +258,8 @@ <h4 id="macOS_virtual_environment_setup">macOS virtual environment setup</h4>

<pre class="brush: bash">sudo pip3 install virtualenvwrapper</pre>

<p>Then add the following lines to the end of your shell startup file.</p>
<p>Then add the following lines to the end of your shell startup file (these are the same lines as for Ubuntu).
If you're using the <em>zsh shell</em> then the startup file will be a hidden file named <strong>.zshrc</strong> in your home directory. If you're using the <em>bash shell</em> then it will be a hidden file named <strong>.bash_profile</strong>. You may need to create the file if it does not yet exist.</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a .bashrc as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even on mac? Either way, I plan only to mention .bash_profile because that is what was tested when this was done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on Sabayon Linux :-)
We have all sorts of shells available.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're a sick sick man :-). We have to draw the line somewhere - this is an 80/20 rule - most people will use the default shell on the most popular distributions. Those that don't are probably experienced enough to know how their shell works.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would most likely be the bash on Linux systems (I'm not quite sure, whether Ubuntu uses the dash).


<pre class="brush: bash">export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
Expand All @@ -283,27 +280,26 @@ <h4>Note</h4>
<p>You can find the correct locations for your system using the commands <code>which virtualenvwrapper.sh</code> and <code>which python3</code>.</p>
</div>

<p>These are the same lines as for Ubuntu, but the startup file is the differently named hidden file <strong>.bash_profile</strong> in your home directory.</p>
<p>Then reload the startup file by making the following call in the terminal:</p>

<pre class="brush: bash">source ~/.bash_profile</pre>

<p>At this point, you may see a bunch of scripts being run (the same scripts as for the Ubuntu installation). You should now be able to create a new virtual environment with the <code>mkvirtualenv</code> command.</p>

<div class="notecard note">
<h4>Note</h4>
<p>If you can't find <strong>.bash_profile</strong> to edit in the finder, you can also open this in the terminal using nano.</p>
<p>If you can't find the startup file to edit in the finder, you can also open this in the terminal using nano.</p>

<p>The commands look something like this:</p>
<p>Assuming you're using bash, the commands look something like this:</p>

<pre><code>cd ~ # Navigate to my home directory
<pre class="brush: bash">cd ~ # Navigate to my home directory
ls -la #List the content of the directory. YOu should see .bash_profile
nano .bash_profile # Open the file in the nano text editor, within the terminal
# Scroll to the end of the file, and copy in the lines above
# Use Ctrl+X to exit nano, Choose Y to save the file.</code>
</pre>
# Use Ctrl+X to exit nano, choose Y to save the file.</pre>
</div>

<p>Then reload the startup file by making the following call in the terminal:</p>

<pre class="brush: bash">source ~/.bash_profile</pre>

<p>At this point, you may see a bunch of scripts being run (the same scripts as for the Ubuntu installation). You should now be able to create a new virtual environment with the <code>mkvirtualenv</code> command.</p>

<h4 id="Windows_10_virtual_environment_setup">Windows 10 virtual environment setup</h4>

Expand Down Expand Up @@ -434,7 +430,7 @@ <h2 id="In_this_module">In this module</h2>

<ul>
<li><a href="/en-US/docs/Learn/Server-side/Django/Introduction">Django introduction</a></li>
<li><a href="/en-US/docs/Learn/Server-side/Django/development_environment">Setting up a Django development environment</a></li>
<li><strong>Setting up a Django development environment</strong></li>
<li><a href="/en-US/docs/Learn/Server-side/Django/Tutorial_local_library_website">Django Tutorial: The Local Library website</a></li>
<li><a href="/en-US/docs/Learn/Server-side/Django/skeleton_website">Django Tutorial Part 2: Creating a skeleton website</a></li>
<li><a href="/en-US/docs/Learn/Server-side/Django/Models">Django Tutorial Part 3: Using models</a></li>
Expand Down