Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Flashcards

 I know I could buy a polished flashcard app for about twenty or thirty dollars. That would be the quickest solution. But this project is not about convenience. It is about practicing skills I enjoy, exploring my tools more deeply, and shaping a system that integrates Japanese study, Obsidian, and my own local models. Building it myself is the point.



The first step is a simple Python command-line tool. It loads a CSV with Japanese words and meanings, presents each question, accepts my typed answer, and checks if I am correct. This early stage is perfect for debugging the essentials: reading the CSV, trimming input, comparing answers, and tracking a basic mastery score. It lets me experiment freely with no UI overhead. Once this logic behaves well, everything else becomes straightforward.


The second piece is the language model, and I keep it where it belongs: in the command line. Instead of trying to embed MLX into a Swift app, I let the LLM run locally in Python. From there it can handle two jobs. First, it can compare my typed answers with the official ones and judge whether my response is close enough, which is helpful for Japanese phrasing, minor spelling differences, and synonyms. Second, it can scan selected markdown files in my Obsidian vault and extract new question–answer pairs. This allows me to grow my flashcard set automatically from whatever I am studying at the moment.



The macOS SwiftUI app is still useful, but now it becomes a thin layer on top. It can display cards, accept input, and call the Python scripts when needed. The heavy logic stays in Python, where MLX runs efficiently and where I can maintain a clean separation between UI and computation. The app becomes a comfortable window, while the command line remains the engine.


Obsidian ties the whole idea together. I already keep a large amount of Japanese material, notes, fragments, and vocabulary in my vault. A simple Python script can read those markdown files, provide them as context to the LLM, and extract neatly formatted Q&A pairs. The system then feeds those back into the CSV or writes new markdown, closing the loop between learning, reading, and structured review.


The overall plan stays simple and scalable. Start with a pure Python CLI to get the core behavior right. Add a command-line LLM layer for fuzzy answer checking and automatic question generation. Build a small macOS SwiftUI interface on top, with the Python engine running behind it. And finally, use Obsidian as both the source and destination of knowledge. The project is not meant to compete with commercial apps. It is a practice ground for Python, Swift, MLX, and knowledge workflows that match how I actually learn




As an Amazon Associate I earn from qualifying purchases.

Recurrent Neural Network (RNN) cell in PyTorch

This minimal PyTorch example implements a custom recurrent neural network (RNN) cell from first principles, showing how sequence memory emerges through feedback.
The cell maintains a hidden state vector h, which evolves over time using the current input x and the previous hidden state through the nonlinear update h = tanh(Wₕₕh + Wₓₕx). The output y = Wₕy h is then computed as a simple linear projection of the hidden state.
Unlike PyTorch’s built-in nn.RNN, this implementation makes every matrix and operation explicit, clearly illustrating how temporal dependencies are learned through recursive state updates rather than static input-output mappings.

code: https://github.com/UkiDLucas/DNN-book



import torch
import torch.nn as nn

# pick device (use "mps" on Apple Silicon;
# macOS Metal hardware acceleration
device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")

class MyRNNCell(nn.Module):
# rnn_units: number of hidden neurons
def __init__(self, rnn_units, input_dim, output_dim):
super().__init__()
# weight matrices, * 0.01 scales the random weight initialization to small values
self.W_xh = nn.Parameter(torch.randn(rnn_units, input_dim) * 0.01)
self.W_hh = nn.Parameter(torch.randn(rnn_units, rnn_units) * 0.01)
self.W_hy = nn.Parameter(torch.randn(output_dim, rnn_units) * 0.01)
# hidden state h initialized to zeros
self.register_buffer("h", torch.zeros(rnn_units, 1))

def forward(self, x):
# x is shape [input_dim, 1]
self.h = torch.tanh(self.W_hh @ self.h + self.W_xh @ x)
y = self.W_hy @ self.h
return y, self.h
# minimal usage example


if __name__ == "__main__":
rnn = MyRNNCell(rnn_units=16, input_dim=8, output_dim=4).to(device)
x_t = torch.randn(8, 1, device=device) # input vector at time t
y_t, h_t = rnn(x_t)
print(y_t.shape, h_t.shape) # torch.Size([4, 1]) torch.Size([16, 1])


A practical use of this minimal RNN cell is to predict or generate sequential data, where each step depends on the previous one.

For example:

  • Time series forecasting: Feed in one value at a time (like daily temperatures or stock prices) and train it to predict the next value.

  • Character-level text generation: Convert characters to one-hot vectors, feed them sequentially, and let the RNN learn to predict the next character.

  • Signal smoothing or sensor prediction: Use it to process sequential readings (like a boat’s wind and wave sensors) to predict future conditions.

Even though it’s a tiny model, it demonstrates the whole idea: maintaining internal memory (h) to connect past inputs with future outputs.

Various RNN configurations:

  • single input >  RNN cell > single result for binary classification
  • many inputs > many RNN cells > single output: sentiment classification
  • single input > many RNN cells > many outputs: text generation, image captions
  • many inputs > many RNN cells > many outputs: translation, music generation

Think of an RNN as a storyteller that remembers what has already been said while deciding what comes next. Each RNN cell is like one frame in a film reel—receiving new input, updating its memory, and passing that memory forward. When you connect many cells in series, the network forms a chain of thought through time: it doesn’t see the whole story at once but recalls what just happened. In a simple one-to-one setup, it’s like hearing a single word and deciding “yes” or “no.” With many inputs feeding into a single output, it listens to a whole sentence before forming an opinion, such as judging sentiment. With one input producing many outputs, it’s as if the RNN takes one idea and tells a whole story, step by step. And when many inputs produce many outputs, it becomes a fluent translator or composer—listening, remembering, and responding continuously.

References:



As an Amazon Associate I earn from qualifying purchases.

Best Neural Network framework to run on macOS M1.

Choosing the best Neural Network framework to run on my macOS M1 64 GB RAM workstation.
Neural network frameworks on macOS M1 with native acceleration
Framework Programming language M1 acceleration rating
PyTorch (MPS backend) Python, C++ 9/10
TensorFlow + tensorflow-metal Python, C++ 8/10
Core ML (inference) Swift, Python bridge 10/10
ONNX Runtime (Core ML/Metal delegate) C++, Python API 7/10
JAX (Metal backend) Python 6/10
MXNet Python, C++ 3/10
CNTK Python, C++ 3/10
Theano Python 3/10


As an Amazon Associate I earn from qualifying purchases.

Mastering Time: How 365 Days of Habits Can Transform Your Life

In this post, I reflect on the profound impact of habits and effective time management over a year. 

I share personal experiences and strategies on how small daily habits contribute to success through steady, incremental improvements. 

I highlight the exponential growth in skills and investments and illustrate the compound effects of daily disciplines. 

I also delve into my personal routines and how they enhance my productivity and overall success.


How do I manage my time?


The answer boils down to habits.

Before discussing habits, I would like to talk about exponential growth.




Why is exponential growth a crucial concept for success?

Whether it is an investment of time in building expertise or finances,
exponential growth is a gateway to personal success. 

Let's assume we have a starting state (or baseline);
this could be a $100 bill saved under the bed mattress or your current skillset. 

If we leave it under the mattress for a year, we will still have $100. 

We must understand that we do not want to add a tiny bit by putting a single cent under the mattress.

We use the baseline, or the capital we have, to increase the whole by 0.01 daily,
or reinvest what you have.

  • So, doing nothing, we still have $100
  • Daily adding a cent (0.01 of a dollar) leaves us with $103.65
  • Reinvesting the capital and increasing it by 0.01 daily gives us $37,783
Doing nothing or saving does NOT work in life

Reinvesting works!

As a nerdy scientist, I had to write a program that shows this. 







Can you imagine what would this give you over 10 years?

Wait, wait, kaboom!  


I know constantly growing your capital at 1% (0.01) daily is not sustainable.

I gave you the numbers for dramatic effect. Otherwise, you would not be impressed.


Skills do grow at an exponential rate.

Think about car driving. 

At first, you go slow and wobbly, but soon after, you are cruising on the highway at 85 mph while eating a hamburger with one hand and drinking a 24-oz Coke with another. There are so many things wrong with this picture.


What are my time management habits?

I get plenty of sleep; it is crucial. I am writing this first because I know plenty of people who like living on credit. Trust me, this creditor is merciless. Do not borrow here.

I get up at 5 AM every day of the week.
I tried to get up at zero-dark-thirty for a while, but I was tired all day. 5 a.m. is just right.

My best thinking time is early morning before people show up. I guard this time for the best intellectual work.

I use the 15-minute retrospective rule. Review how you have spent the last 15 minutes and ask yourself if it improved your life. If not, change what you are doing.

I do not like wasting time. I treasure a good conversation with a friend, I like poetry, and I stop to smell flowers or at least take a photo, but I hate wasting time.

Social Media kills our productivity. I watch many videos but always do it to learn something interesting.

Gaming kills productivity. I am considering them as an equivalent of hard drugs and allow none.

I try to be in the office every workday. I do not believe in working from home. You have to be present and in the action, or you lose.

I like taking time off at midday, walking during lunchtime, or napping. The latter is difficult at work, but I will do it when I retire. 


How do I learn new habits?

Many will say that getting up at 5 a.m. and watching every 15 minutes is crazy and too hard. 

I could talk about motivation and setting the right environment to avoid excuses, but I no longer believe in that.

It is hard to explain, but being a Stoic Philosopher or at least a follower does it for me.

When I face a decision to do it or be lazy, a voice in my head says to me:

"You are not the kind of person to make this bad decision." 

That is all, voices in my head. :)



View on Amazon:



Please SUBSCRIBE: https://ukidlucas.beehiiv.com/



As an Amazon Associate I earn from qualifying purchases.

mlx-lm

MLX LM is a Python package for generating text and fine-tuning large language models on Apple silicon with MLX

https://pypi.org/project/mlx-lm/#description

% pip install mlx-lm


As an Amazon Associate I earn from qualifying purchases.

FreeCAD

 I found this good FreeCAD Python macro programming YouTube playlist:






As an Amazon Associate I earn from qualifying purchases.

freeCAD

I came across FreeCAD software in the context of sailboat design.
I don't know how useful or easy it is to learn, but I found some promising results online. 

https://forum.freecad.org/viewtopic.php?t=64136&start=10

Here is the download page for MacOS, Linux, and Windows.
https://www.freecad.org/downloads.php

From the FreeCAD page:

"While the FreeCAD core functionality is coded in C++ for robustness and performance, large parts of the external layers, workbenches, and almost all the communication between the core and the user interface is coded in Python, a flexible, user-friendly, easy-to-learn programming language. From Python code, you can do just anything in FreeCAD, from simple one-line commands in the integrated Python console to recording macros, coding your own tools up to full custom workbenches."







As an Amazon Associate I earn from qualifying purchases.

Point Cloud Library (PCL) on Mac OS

Install PCL using BREW.

PCL is a Point Cloud Library for C++

$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates



After updating Mac OS, please re-install the brew:

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



$ brew update

Already up-to-date.

$ brew tap homebrew/science
Error: homebrew/science was deprecated. This tap is now empty as all its formulae were migrated.

$ brew tap brewsci/science


Cloning into '/usr/local/Homebrew/Library/Taps/brewsci/homebrew-science'...

DANGER (no need to do it if you re-insalled the brew):
$ sudo install -d -o $(whoami) -g admin /usr/local/Frameworks

$ brew reinstall pcl

🍺  /usr/local/Cellar/pcl/1.9.1_4: 1,173 files, 147.4MB


$ brew upgrade pcl

Error: pcl 1.9.1_4 already installed


Compile the Lidar Simulator (Udacity nd313)

cd /Volumes/DATA/_Drive/_REPOS/SFND_Lidar_Obstacle_Detection/build/

build $ rm ../CMakeCache.txt





build $ cmake ../CMakeLists.txt
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking for module 'eigen3'
--   No package 'eigen3' found
-- Found Eigen: /usr/local/include/eigen3 
-- Eigen found (include: /usr/local/include/eigen3, version: 3.3.7)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE 
-- Boost version: 1.70.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono
--   atomic
--   regex
-- Checking for module 'flann'
--   No package 'flann' found
-- Found FLANN: /usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib 
-- FLANN found (include: /usr/local/Cellar/flann/1.9.1_7/include, lib: optimized;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib;debug;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib)
-- Checking for module 'flann'
--   No package 'flann' found
-- FLANN found (include: /usr/local/Cellar/flann/1.9.1_7/include, lib: optimized;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib;debug;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- Found libusb-1.0: /usr/local/include 
** WARNING ** io features related to libusb-1.0 will be disabled
-- Found Qhull: optimized;/usr/local/lib/libqhull_p.dylib;debug;/usr/local/lib/libqhull_p.dylib 
-- QHULL found (include: /usr/local/include, lib: optimized;/usr/local/lib/libqhull_p.dylib;debug;/usr/local/lib/libqhull_p.dylib)
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework 
-- Found PkgConfig: /opt/local/bin/pkg-config (found version "0.29.2")
-- Checking for module 'glew'
--   No package 'glew' found
CMake Error at /usr/local/share/pcl-1.9/PCLConfig.cmake:58 (message):
  simulation is required but glew was not found
Call Stack (most recent call first):
  /usr/local/share/pcl-1.9/PCLConfig.cmake:361 (pcl_report_not_found)
  /usr/local/share/pcl-1.9/PCLConfig.cmake:545 (find_external_library)
  CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Volumes/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeFiles/CMakeOutput.log".
See also "/Volumes/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeFiles/CMakeError.log".





$ brew install glew

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.

Warning: glew 2.1.0 is already installed and up-to-date
To reinstall 2.1.0, run `brew reinstall glew`
(turi) uki  16:17 build $





References











As an Amazon Associate I earn from qualifying purchases.

Point Cloud Library (PCL) on Mac OS

Install PCL using BREW.

PCL is a Point Cloud Library for C++

$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates



After updating Mac OS, please re-install the brew:

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



$ brew update

Already up-to-date.

$ brew tap homebrew/science
Error: homebrew/science was deprecated. This tap is now empty as all its formulae were migrated.

$ brew tap brewsci/science


Cloning into '/usr/local/Homebrew/Library/Taps/brewsci/homebrew-science'...

DANGER (no need to do it if you re-insalled the brew):
$ sudo install -d -o $(whoami) -g admin /usr/local/Frameworks

$ brew reinstall pcl

🍺  /usr/local/Cellar/pcl/1.9.1_4: 1,173 files, 147.4MB


$ brew upgrade pcl

Error: pcl 1.9.1_4 already installed


Compile the Lidar Simulator (Udacity nd313)

cd /Volumes/DATA/_Drive/_REPOS/SFND_Lidar_Obstacle_Detection/build/

build $ rm ../CMakeCache.txt





build $ cmake ../CMakeLists.txt
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking for module 'eigen3'
--   No package 'eigen3' found
-- Found Eigen: /usr/local/include/eigen3 
-- Eigen found (include: /usr/local/include/eigen3, version: 3.3.7)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE 
-- Boost version: 1.70.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono
--   atomic
--   regex
-- Checking for module 'flann'
--   No package 'flann' found
-- Found FLANN: /usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib 
-- FLANN found (include: /usr/local/Cellar/flann/1.9.1_7/include, lib: optimized;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib;debug;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib)
-- Checking for module 'flann'
--   No package 'flann' found
-- FLANN found (include: /usr/local/Cellar/flann/1.9.1_7/include, lib: optimized;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib;debug;/usr/local/Cellar/flann/1.9.1_7/lib/libflann_cpp.dylib)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- Found libusb-1.0: /usr/local/include 
** WARNING ** io features related to libusb-1.0 will be disabled
-- Found Qhull: optimized;/usr/local/lib/libqhull_p.dylib;debug;/usr/local/lib/libqhull_p.dylib 
-- QHULL found (include: /usr/local/include, lib: optimized;/usr/local/lib/libqhull_p.dylib;debug;/usr/local/lib/libqhull_p.dylib)
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework 
-- Found PkgConfig: /opt/local/bin/pkg-config (found version "0.29.2")
-- Checking for module 'glew'
--   No package 'glew' found
CMake Error at /usr/local/share/pcl-1.9/PCLConfig.cmake:58 (message):
  simulation is required but glew was not found
Call Stack (most recent call first):
  /usr/local/share/pcl-1.9/PCLConfig.cmake:361 (pcl_report_not_found)
  /usr/local/share/pcl-1.9/PCLConfig.cmake:545 (find_external_library)
  CMakeLists.txt:10 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Volumes/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeFiles/CMakeOutput.log".
See also "/Volumes/DATA/_Drive/_REPOS/SFND313_Lidar_Obstacle_Detection/CMakeFiles/CMakeError.log".





$ brew install glew

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.

Warning: glew 2.1.0 is already installed and up-to-date
To reinstall 2.1.0, run `brew reinstall glew`
(turi) uki  16:17 build $





References











As an Amazon Associate I earn from qualifying purchases.

Basemap


Plotting geolocations with Python and Basemap





https://jakevdp.github.io/PythonDataScienceHandbook/04.13-geographic-data-with-basemap.html




As an Amazon Associate I earn from qualifying purchases.

Basemap


Plotting geolocations with Python and Basemap





https://jakevdp.github.io/PythonDataScienceHandbook/04.13-geographic-data-with-basemap.html




As an Amazon Associate I earn from qualifying purchases.

multi_cam_pi

https://www.pyimagesearch.com/2016/01/18/multiple-cameras-with-the-raspberry-pi-and-opencv/


As an Amazon Associate I earn from qualifying purchases.

multi_cam_pi

https://www.pyimagesearch.com/2016/01/18/multiple-cameras-with-the-raspberry-pi-and-opencv/


As an Amazon Associate I earn from qualifying purchases.

Fabric Python library to run SSH to multiple computers

Fabric Python library can be used to send SSH commands to multiple computers at the same time.

This comes useful when doing distributed updates to the SBC (i.e. Raspberry Pi) cluster.

http://www.fabfile.org/




As an Amazon Associate I earn from qualifying purchases.

Fabric Python library to run SSH to multiple computers

Fabric Python library can be used to send SSH commands to multiple computers at the same time.

This comes useful when doing distributed updates to the SBC (i.e. Raspberry Pi) cluster.

http://www.fabfile.org/




As an Amazon Associate I earn from qualifying purchases.

Installing Turi Create on Python 3.6 Anaconda Environment

Installing TuriCreate on Python 3.6 Anaconda Environment

1) Check what Python version Apple Turi Create supports



Turi Create requires:
  • Python 2.7, 3.5, 3.6

2) Switch to Python 3.6 environment

$ source activate py36



$ conda env list
# conda environments:
/Users/uki/.julia/conda/3
/Users/uki/.julia/packages/ORCA/uEiWT/deps
base /Volumes/DATA/anaconda3
py2 /Volumes/DATA/anaconda3/envs/py2
py36 * /Volumes/DATA/anaconda3/envs/py36

3) Find TuriCreate v5.1.0 package

Browse: https://anaconda.org/derickl/turicreate

$ conda install -c derickl turicreate

4) Install Jupyter Notebook kernel conda module 


$ conda install ipykernel

5) Make sure all the packages are matching and updated

$ conda update --all

6) Install Jupyter Notebook kernel with this Environment


python -m ipykernel install --user --name py36 --display-name "Python 3.6 Turi (env py36)"
Installed kernelspec py36 in /Users/uki/Library/Jupyter/kernels/py36

7) Backup your Environment

Just because things go wrong all the time.

$ conda env export > environment_py36_20181102.yml

8) Start Jupyter notebook


$ jupyter notebook



Test Turi in Jupyter Notebook


import turicreate as turi
WARNING: You are using MXNet 1.2.1 which may result in breaking behavior. To fix this, please install the currently recommended version: pip uninstall -y mxnet && pip install mxnet==1.1.0 If you want to use a CUDA GPU, then change 'mxnet' to 'mxnet-cu90' (adjust 'cu90' depending on your CUDA version):




(py36) $ pip uninstall -y mxnet && pip install mxnet==1.1.0














As an Amazon Associate I earn from qualifying purchases.

Installing Turi Create on Python 3.6 Anaconda Environment

Installing TuriCreate on Python 3.6 Anaconda Environment

1) Check what Python version Apple Turi Create supports



Turi Create requires:
  • Python 2.7, 3.5, 3.6

2) Switch to Python 3.6 environment

$ source activate py36



$ conda env list
# conda environments:
/Users/uki/.julia/conda/3
/Users/uki/.julia/packages/ORCA/uEiWT/deps
base /Volumes/DATA/anaconda3
py2 /Volumes/DATA/anaconda3/envs/py2
py36 * /Volumes/DATA/anaconda3/envs/py36

3) Find TuriCreate v5.1.0 package

Browse: https://anaconda.org/derickl/turicreate

$ conda install -c derickl turicreate

4) Install Jupyter Notebook kernel conda module 


$ conda install ipykernel

5) Make sure all the packages are matching and updated

$ conda update --all

6) Install Jupyter Notebook kernel with this Environment


python -m ipykernel install --user --name py36 --display-name "Python 3.6 Turi (env py36)"
Installed kernelspec py36 in /Users/uki/Library/Jupyter/kernels/py36

7) Backup your Environment

Just because things go wrong all the time.

$ conda env export > environment_py36_20181102.yml

8) Start Jupyter notebook


$ jupyter notebook



Test Turi in Jupyter Notebook


import turicreate as turi
WARNING: You are using MXNet 1.2.1 which may result in breaking behavior. To fix this, please install the currently recommended version: pip uninstall -y mxnet && pip install mxnet==1.1.0 If you want to use a CUDA GPU, then change 'mxnet' to 'mxnet-cu90' (adjust 'cu90' depending on your CUDA version):




(py36) $ pip uninstall -y mxnet && pip install mxnet==1.1.0














As an Amazon Associate I earn from qualifying purchases.

graphlab.canvas.set_target('ipynb') error

I am getting an error in the following line:

graphlab.canvas.set_target('ipynb') # alternative 'browser', port=8889


/Volumes/DATA/anaconda3/envs/py27/lib/python2.7/site-packages/graphlab/canvas/server.pyc
108 self.__server = tornado.httpserver.HTTPServer(self.__application, io_loop=self.__loop)
TypeError: initialize() got an unexpected keyword argument 'io_loop'

Fix Attempt 1:

 

$ conda update tornado


environment location: /Volumes/DATA/anaconda3/envs/py27


tornado: 5.1-py27h1de35cc_0 --> 5.1.1-py27h1de35cc_0

Fix is not successful



Fix Attempt 2:


Reinstall Anaconda3


As an Amazon Associate I earn from qualifying purchases.

graphlab.canvas.set_target('ipynb') error

I am getting an error in the following line:

graphlab.canvas.set_target('ipynb') # alternative 'browser', port=8889


/Volumes/DATA/anaconda3/envs/py27/lib/python2.7/site-packages/graphlab/canvas/server.pyc
108 self.__server = tornado.httpserver.HTTPServer(self.__application, io_loop=self.__loop)
TypeError: initialize() got an unexpected keyword argument 'io_loop'

Fix Attempt 1:

 
$ conda update tornado
environment location: /Volumes/DATA/anaconda3/envs/py27
tornado: 5.1-py27h1de35cc_0 --> 5.1.1-py27h1de35cc_0
Fix is not successful


Fix Attempt 2:

Reinstall Anaconda3


As an Amazon Associate I earn from qualifying purchases.

Install Anaconda Python environment with Jupyter Notebook

This post was updated on September 29, 2022

Check if you have Conda installed

% conda update --all -y
>> command not found: conda

Install Anaconda Python

I prefer an installer on my laptop: 


After installation, make sure you restart the Terminal (control N).

Note, Anaconda includes the following and much more:
  • curl

  • numpy

  • matplotlib

  • jupyter_core

  • protobuf

  • sqlite

  • ipython

  • jupyterlab

  • jupyter

  • notebook

  • matplotlib

  • pip

  • pandas

  • pillow

  • scikit-learn

  • python-3.9



Update Conda


$ conda activate base
$ conda update -n base -c defaults conda
$ conda update --all -y



How to start Jupyter Notebook



cd $REPO // the directory you want as a base of your project (e.g. in GitHub directory)  
jupyter-lab

This will start in the browser: http://localhost:8888/lab


That is all you need to start working.
Alternatively, you may want to create ENVIRONMENT specific installation. This is useful if you work on multiple projects, especially over a long time when LIBRARIES change and code becomes outdated.


Check Python Version that came with Conda

% python --version
Python 3.9.13

 

Create a Conda TensorFlow environment

$ conda create -n py_39_tf python=3.9 tensorflow -y

This installs tensorflow         pkgs/main/osx-64::tensorflow-2.9.1

List conda environments you already created



$ conda info --envs

 

% conda info --envs

# conda environments:

#

base                  *  /Users/uki/opt/anaconda3

py_39_tf                 /Users/uki/opt/anaconda3/envs/py_39_tf





Activate the Conda Environment you want Jupyter in.


% conda activate py_39_tf

(py_39_tf) uki ~ %






Install new Jupyther kernel


$ python -m ipykernel install --user --name py_36_tf --display-name "Python 3.6 (tensorflow)"



 



List currently installed Jupyther kernels 



$ ls -alt ~/Library/Jupyter/kernels/


total 0
drwx------ 7 uki staff 224 Nov 22 11:50 ..
drwxr-xr-x 9 uki staff 288 Nov 22 11:43 .
drwxr-xr-x 5 uki staff 160 Nov 4 06:35 julia-1.4
drwxr-xr-x 5 uki staff 160 Apr 1 2020 python361064bitpy36condaa60168e76a7b4349b469299762ee4c30
drwxr-xr-x 5 uki staff 160 Apr 1 2020 python38264bitpytorchcondaaf5a833263b448b8b2738bb5a7355c8a
drwxr-xr-x 5 uki staff 160 Apr 1 2020 python361064bitturiconda565ecc262d0845fbb235ae21ac24296f












Installed kernelspec py_36_tf in /Users/uki/Library/Jupyter/kernels/py_36_tf

Refresh a page with Jupyther Lab notebook and change to the new kernel.




Delete kernels that you want to replace


$ rm -r ~/Library/Jupyter/kernels/my_old_kernel_name

 



As an Amazon Associate I earn from qualifying purchases.

apt quotation..