Skip to content

Instantly share code, notes, and snippets.

@arsho
Last active May 23, 2019 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arsho/9a1e4ac9221c50d754a90a7291a12602 to your computer and use it in GitHub Desktop.
Save arsho/9a1e4ac9221c50d754a90a7291a12602 to your computer and use it in GitHub Desktop.
Install Miniconda in Ubuntu 16.04 keeping the default Python versions. Use conda environment in Ubuntu. Anaconda. Install Chatterbot using Python 3.7

Installing chatterbot in conda environment using Python 3.7

  • Create new conda environment with Python 3.7
conda create --name chatterbot_example python=3.7
  • Activate the environment:
source activate chatterbot_example
  • Install chatterbot and chatterbot-corpus inside the environment:
pip install chatterbot
pip install chatterbot-corpus
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")

# Get a response to an input statement
print(chatbot.get_response("Hello, how are you today?"))
  • Run the program:
python example.py

Output:

python example.py
[nltk_data] Downloading package stopwords to /home/cefalo/nltk_data...
[nltk_data]   Package stopwords is already up-to-date!
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data]     /home/cefalo/nltk_data...
[nltk_data]   Package averaged_perceptron_tagger is already up-to-
[nltk_data]       date!
Training ai.yml: [####################] 100%
Training botprofile.yml: [####################] 100%
Training computers.yml: [####################] 100%
Training conversations.yml: [####################] 100%
Training emotion.yml: [####################] 100%
Training food.yml: [####################] 100%
Training gossip.yml: [####################] 100%
Training greetings.yml: [####################] 100%
Training health.yml: [####################] 100%
Training history.yml: [####################] 100%
Training humor.yml: [####################] 100%
Training literature.yml: [####################] 100%
Training money.yml: [####################] 100%
Training movies.yml: [####################] 100%
Training politics.yml: [####################] 100%
Training psychology.yml: [####################] 100%
Training science.yml: [####################] 100%
Training sports.yml: [####################] 100%
Training trivia.yml: [####################] 100%
Tell me a joke

System information:

  • OS : Ubuntu 16.04 LTS
  • Processor : Intel® Core™ i7-4600M

Conda version information:

conda --version
conda 4.5.11

Installed packages:

attrs==19.1.0
blis==0.2.4
certifi==2019.3.9
chardet==3.0.4
ChatterBot==1.0.5
chatterbot-corpus==1.2.0
cymem==2.0.2
idna==2.8
jsonschema==3.0.1
mathparse==0.1.2
murmurhash==1.0.2
nltk==3.4.1
numpy==1.16.3
Pint==0.9
plac==0.9.6
preshed==2.0.1
pymongo==3.8.0
pyrsistent==0.15.2
python-dateutil==2.7.5
pytz==2019.1
PyYAML==3.13
requests==2.22.0
six==1.12.0
spacy==2.1.4
SQLAlchemy==1.2.19
srsly==0.0.5
thinc==7.0.4
tqdm==4.32.1
urllib3==1.25.2
wasabi==0.2.2

What is Miniconda?

Miniconda is a mini version of Anaconda that includes only conda and its dependencies. It contains the conda package manager and Python.

Pros

  • Using Miniconda we can install various Python versions in same machine.
  • We can install different version of same packages completely independent of system/global site packages.

Cons

  • At the last step of installing Miniconda, it asks the user choice for:
    Do you wish the installer to prepend the conda install location to PATH in your /root/.bashrc ? [yes|no]
    
  • If user puts yes, it will override default Python versions of the System and will use Miniconda's Python afterwards.

How to install Miniconda without overriding installed Python versions?

(The following steps are for Linux / MacOS machines)

Follow these steps to install and use Miniconda along with the System's default Python versions.

  • Download and install Miniconda Python 3.7 64 Bit installer from https://conda.io/miniconda.html
  • At the last step of installing Miniconda, it asks the user choice for:
    Do you wish the installer to prepend the conda install location to PATH in your /root/.bashrc ? [yes|no]
    
    Enter no
  • Create symbolic Links for conda commands:
    • Go to home directory and Open a terminal there:
    • Create a directory:
      mkdir .symlinks   
      
    • Change current directory to the new created directory:
      cd .symlinks
      
    • Add the following symbolic links
      ln -s /home/cefalo/miniconda3/bin/conda conda
      ln -s /home/cefalo/miniconda3/bin/activate activate
      ln -s /home/cefalo/miniconda3/bin/deactivate deactivate
      
    • In /home/cefalo/.bashrc file add
      export PATH=/home/cefalo/.symlinks:$PATH
      
    • (Optional) if you use zsh, you need to add the path in /home/celfao/.zshrc also
      export PATH=/home/cefalo/.symlinks:$PATH
      
  • Close the terminal and open it again.
  • Check conda version:
    conda --version
    conda 4.5.11
    
  • Create an environment using conda:
    conda create --name venv_python3.7 python=3.7
    
  • Activating the environment:
    source activate venv_python3.7
    
  • Check environments created by Conda:
    conda info --envs
    
  • Deactivating the environment:
    source deactivate
    
  • Deleting an existing environment:
    conda remove --name myenv --all
    

References

@arsho
Copy link
Author

arsho commented Jan 5, 2019

conda create --name venv_notebooks python=3.7
source activate venv_notebooks
pip install --upgrade pip
pip install --upgrade ipython jupyter
jupyter notebook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment