Skip to main content

Posts

Showing posts from 2018

Installing virtualenv in Custom MSC Linux board

I am currently working on a Python project which runs on MSC board (with custom Linux OS). Even installing something as basic as virtualenv on this board needed some 'efforts'.  So, I decided to summarize the steps that helped me to get python virtual environment working on this Linux based board.  Hopefully, it might also help some other developers facing similar issues.   Install virtualenv package     I had to use ' --trusted-host ' flag for both pypi.org and      ' files. pythonhosted.org ' to avoid ssl certificate errors.      However, use of this flag should be avoided in general      because it overrides some essential security checks.          python3.6 -m pip install --trusted-host= pypi.org virtualenv      --trusted-host= files. pythonhosted.org Define symbolic library path     We need to define path of ' libpython' symbolic library      corresponding to the Python version installed in MSC Board.      Otherwise

Hosting your Django app in Cloud Based Server

Let’s say that you have a solid business plan and you decide to go with Python and Django framework to take this project from concept to reality. One of the most fundamental things to do at this stage is to find a Django-friendly hosting service. Since Django framework has a special syntax and structure, it’s important to make sure that a chosen provider makes it possible to easily deploy and scale any Django project. There are many Django-compatible hosting providers which are worth considering. This post documents my experience deploying a basic Python based web app in " PythonAnywhere". PythonAnywhere runs on powerful Amazon EC2 servers and it is pre-configured with tons of libraries. Steps: Create a free user account in GitHub.com (If you haven't done it yet!)           Then, create a new repository, giving it the name. My test project was named " DjangoTest ". Set up our Django Test App on PythonAnywhere Sign up for a Pytho

Installing g++ compiler on Windows

Download MinGW - Minimalist GNU for Windows from below link –                 https://sourceforge.net/ projects/mingw/ Now run the installer as admin. It will download some files and then open the MinGW download manager Select MinGW base and MinGW G++ (for c++ compilation) check boxes Go to File -> Apply Changes. The selected options will be installed. Add the below path to System Path in environment variable                 “C:\MinGW\bin” Now you can try to verify in g++ is installed properly by running the below command in Command Promt –                  g++ --version                

32 bit and 64 bit system files in Windows

The windows operating system stores both 32 bit and 64 bit system files under seperate folders.  Because 64 bit OS needs to be able to run 32 bit programs without confusing them with new paths, some paths are redirected to different folders depending on whether a 32 bit or 64 bit application looks at them. The same applies to some registry keys.  Basically, if you open explorer (which is a 64 bit program), you will see these folders: C:\Windows\System32 << your 64 bit system folder C:\Windows\SysWOW64 << your 32 bit system folder (Yes, the numbers appear to be exactly the other way round, looks like someone at Microsoft was trying to be funny!) However: When a 32 bit program, such as Atom, looks at your Windows folder, it will see these folders instead: C:\Windows\System32 << your 32 bit system folder ( !!! ) C:\Windows\Sysnative << your 64 bit system folder This ensures that under the path C:\Windows\System32 , all applicatio

Solving PyCharm bug: "Python helpers are not copied yet..."

I have been using PyCharm Professional to run and debug Python code from my Windows machine to a remote Linux device. There are some other tools available for the same purpose (e.g. Python Tool for Visual Studio 2017). But in my opinion, PyCharm Professional stands out among its counterparts as it comes with a "All Batteries Included" setup. Once you configure remote Python interpreter in PyCharm, then it works out of the box. However, today after upgrading to PyCharm Professional 2018.2.1, I could not run my Python script on remote device. The execution always failed with below error - "Error running 'hello': Python helpers are not copied yet to the remote host. Please wait until remote interpreter initialization finishes." To solve this issue, I had to remove the ".pycharm_helpers " folder from the remove device and then restart PyCharm so that the folder is re-created and files are copied again. Here are the steps with comma

Installing Docker on Azure (Linux) Virtual Machine

Step 1. Update the apt package index: sudo apt-get update Step 2. Install packages to allow apt to use a repository over HTTPS: sudo apt-get install \     apt-transport-https \     ca-certificates \     curl \     software-properties-common Step 3. Add Docker’s official GPG key: curl -fsSL https://download.docker.com/ linux/ubuntu/gpg | sudo apt-key add - Step 4. Set up the stable repository (command depends on system architecture): sudo add-apt-repository \     "deb [arch=amd64] https://download.docker.com/ linux/ubuntu \     $(lsb_release -cs) \     stable" Step 5. Update the package index again: sudo apt-get update Step 6. Install the docker-ce package (the service should start automatically after installation): sudo apt-get install docker-ce Step 7. Verify that docker installed properlty: sudo docker run hello-world

Solving SSH connection issue with Linux Virtual Machine in Azure

I created a Linux Virtual Machine in Azure, but connecting to it through SSH was a real nightmare. I was always getting the below error - "Permission denied (publickey)."  After lot of googling, binging and shooting in the dark, this is how I fixed the problem: Create a new ssh key by running below command.            PS: Do not change the default name or path of generated ssh key.           ssh-keygen -t rsa -b 2048           Generating public/private rsa key pair.           Enter file in which to save the key (/c/Users/<Username>/.ssh/id_rsa):           Enter passphrase (empty for no passphrase):           Enter same passphrase again:           Your identification has been saved in /c/Users/ <Username> /.ssh/id_rsa.           Your public key has been saved in /c/Users/ <Username> /.ssh/id_rsa. pub In Azure portal. Click on your Virtual Machine name,  Select ' Reset Password -> ' Reset SSH ' -> ' Reset SSH

Customized Crosshair with OxyPlot charting library

I am using Oxyplot to draw heatmap for a WPF project and needed to draw a crosshair that moves according to user clicks. Since I couldn't find any good example or documentation on the topic, I made a small hack by using LineAnnotations and by over-riding Oxyplot mouse click event. Here is the sample code using WPF with MVVM pattern- MainWindow.xaml <Grid>         <oxy:Plot x:Name="CrossHairPlot">             <oxy:Plot.Axes>                 <oxy:LinearAxis Key="MyXAxis" Position="Bottom" IsZoomEnabled="False"/>                 <oxy:LinearAxis Key="MyYAxis" Position="Left" IsZoomEnabled="False"/>                 <oxy:LinearColorAxis Key="ZAxis" Position="Top" LowColor="Black"                                                                                      HighColor="White" PaletteSize="300">                     <G

Sharing a folder from Windows 10 host to Ubuntu in Virtual Box

1. First things first! Make sure that you have the latest VirtualBox Guest Additions installed. There are two ways to install it     a. From Ubuntu Desktop Menu Option: Start your VM and select " Devices > Insert Guest Additions CD image ..."     b. From command line with sudo permissions: Execute "VBoxLinuxAdditions.run" file. In my case, it was under path - "/media/VBox_Gas_5.2.6".     sudo /media/VBox_Gas_5.2.6/VBoxLinuxAdditions.run   2. Now share the folder between Windows 10 Host and Ubuntu Guest     a. Create a directory in Windows on any location of your choice.     b. In the VirtualBox, go to the settings of the Ubuntu Guest.     c. Under the Shared Folder section, add the location of you folder created with full permission.     d. Start the ubuntu guest and add your user to the vboxsf group:      sudo usermod -aG vboxsf $(whoami)     e. Logout the user and login again.     Now you can access your shared directory in /media/sf_(shared_folde