How to configure the Django environment and maintain settings?

Asked

Viewed 444 times

1

Hello, I’m starting to learn Django and well part of the material teaches how to Make Environment Setup with Virtualenv. However I am having many difficulties to configure the System.

First, I use a Macbook Pro with OSX Sierra. Second, I have already made the necessary installations, the Homebrew, PIP, virtualenv. But the virtualenv commands do not work. I have tried a LOT of internet solutions, changing the PATH of the files and etc, a lot of same things. One of those times for some reason it worked, but there were so many things I did that I don’t know exactly what made it work. But when I closed the terminal and opened it again everything had stopped working.

I don’t know what I do, I don’t know how I can set it up. My friend who also owned a computer with the same settings as mine managed to have the environment running normally, it was not necessary anything but the installations of the files and everything else. I would like to know what I can do, because I even formatted my Mac to do the environment configuration and it keeps presenting problems when running any command of the dependencies installed.

I’m rather frustrated and annoyed by the situation, if you can help me thank you very much.


Well, I started with these:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install python3

sudo -H easy_install pip

sudo -H pip install virtualenv

sudo -H pip install virutalenvwrapper

Virtualenv’s tried commands were: mkvirtualenv teste Which you returned as an answer: -bash: mkvirtualenv: command not found

  • What commands were tried?

  • @Ciganomorrisonmendez Well I started with these: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install python3

sudo -H easy_install pip

sudo -H pip install virtualenv

sudo -H pip install virutalenvwrapper
 Virtualenv’s tried commands were: mkvirtualenv teste Which returned as respsota: -bash: mkvirtualenv: command not found

  • @Ciganomorrisonmendez I would like to know if there is any way to RESET all the facilities and change File Name and etc I did until then

  • You can always start from scratch. Deleting directories created until then is always an option. See also my answer.

2 answers

0


I’ll give you the steps I made here:

  1. Check whether the virtualenv is working.

    > virtualenv env
    

    Here you have created a directory env as expected.

  2. Install

    > pip install Django
    
  3. Check if you put the configuration of virtualenvwrapper in the profile (~/.bashrc)

    The archive .bashrc of your directory home shall have the following lines:

    export WORKON_HOME=$HOME/.virtualenvs
    source /usr/local/bin/virtualenvwrapper.sh
    
  4. Reload your settings

    No bash, execute:

    > source ~/.bashrc
    

    And then try again:

    > mkvirtualenv teste
    
  • This appeared: when I tried Reload settings: /usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks. 

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is


  • Can you please run this line again? sudo pip install virutalenvwrapper. I need her return (the whole message).

0

Consider "throwing away" the virtual env, seriously! The solution? Anaconda. To install you have two options:

Graphical Installer

  • Download the graphical installer
  • Double click on file . dpkg and follow the instructions

Installation via command line

bash Anaconda3-4.3.1-MacOSX-x86_64.sh  (python 3.6)
bash Anaconda2-4.3.1-MacOSX-x86_64.sh  (python 2.7)

Creating a new env

conda create -n nome_da_env python=2.7  # Env com o python 2
conda create -n py36 python=3.6         # Env com o python 3 

Considerations:

  • Anaconda solves several venv problems, it really works, Voce can install packages normally with Pip or by the actual Conda/anaconda.

  • Anaconda has problems with virtual-env, uninstall it

  • This package solves the problem on Isps where you don’t have root access, like Dreamhost, since it installs python versions, regardless of the system.

  • As anacoda comes as 'teracentos' packages, mainly in the scientific area, some people say that it is heavy and that, in some cases, it is a chanhão to kill a mosquito, but this is ignorance, for this we have the miniconda.

  • Anaconda is a distribution and Conda is an environment/package manager.

Conda: Myths and Misconceptions

Finally, I find it interesting to take a look at that link.

Download the Anaconda.

  • Guy thought this was really cool, it looks really more robust than Python and apparently works better in Python environment. I think I’m gonna test him.

  • Which version will be installed by Python 3 or Python 2. Or both?

  • With Anaconda you can have the 2 environments, so you can download the that version and install python 2 in an isolated container.

  • One remark: When you say "more robust than Python", is making a mistake, anaconda is a python package manager, is a "friend" of python. :-)

  • I wrote it wrong, I am aware of what it is. I just didn’t see that I had written it, sorry.

  • @Jkfher considers giving his acceptance in the reply. :-)

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.