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

Thursday, March 23, 2023

Tensorflow using virtual environments

Tensorflow 2.6(Current version 2.11 at 2023-03-23)

$ sudo apt-get install python3-venv

$ python3 -m venv envtf26

$ source envtf26/bin/activate

(envtf26) cloud@AsusDesktop:~/Gaia$
 


(envtf26) cloud@AsusDesktop:~/Gaia$ pip list  
Package       Version
------------- -------
pip           20.0.2  
pkg-resources 0.0.0   
setuptools    44.0.0

(envtf26) cloud@AsusDesktop:~/Gaia$ pip install tensorflow==2.6


(envtf26) cloud@AsusDesktop:~/Gaia$ pip install --upgrade protobuf==3.20


(envtf26) cloud@AsusDesktop:~/Gaia$ pip install keras==2.6

(envtf26) cloud@AsusDesktop:~/Gaia$ python3           
Python 3.8.10 (default, Mar 13 2023, 10:26:41)  
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf      
>>> print(tf.keras.__version__)  
2.6.0


(envtf26) cloud@AsusDesktop:~/Gaia$ pip install matplotlib==3.6 #if you install without 3.6 will install 3.7 and it will break tensorflow installation

References:

[1] matplotlib compa https://matplotlib.org/stable/devel/min_dep_policy.html








Tuesday, March 21, 2023

Python and OpenCV issues

Error:

   import cv2, numpy as np,time
 File "/home/fincahuanaco/.local/lib/python3.7/site-packages/cv2/__init__.py", line 3, in <module>
   from .cv2 import *
ImportError: numpy.core.multiarray failed to import

 

Solution:

$ python3 -m pip install opencv-python==4.0.0.21

$ python3 -m pip list  
 

opencv-python          4.0.0.21

numpy                  1.15.0

 

Other combinations

opencv_python==4.4.0.46 and numpy==1.19.3 works.

 

Saturday, March 18, 2023

AWS Python issues

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python3 get-pip.py --user
 

References:

[1] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-linux.html

 

Friday, February 17, 2023

Python tools for Web Developers

 

[1] FastAPI https://fastapi.tiangolo.com/

[2] Dash Python https://dash.plotly.com/background-callbacks

 

Friday, November 18, 2022

Gimp Python-Fu

 

[0] https://www.gimp.org/docs/python/index.html#PREGION-OBJECT-MEMBERS

[1] https://www.gimp.org/docs/python/index.html#DRAWABLE-OBJECT-METHODS

[2] http://myvirtualbrain.blogspot.com/2012/06/gimp-python-fu-very-basics.html 

[3] Samples https://github.com/jfmdev/PythonFuSamples

[4] https://github.com/gummyCowboy/GIMP-python-fu

[5] https://gist.github.com/garystafford/5259576a7e9299d5b80284489aa25fc3


Monday, April 25, 2022

Python tools

#Force to install a version Python-3.7.4

 wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz

tar xvf Python-3.7.4.tgz
cd Python-3.7.4
./configure --enable-optimizations --with-ensurepip=install
make -j 8
sudo make altinstall



#Install pip module into any version of Python

curl -o get-pip.py https://bootstrap.pypa.io/pip/get-pip.py
python3.8 get-pip.py  #or
python3.9 get-pip.py

Wednesday, March 23, 2022

Stock Price Prediction - data source

 

[1] Nasdaq API https://data.nasdaq.com/sign-up 

[2] API https://data.nasdaq.com/tools/python (API is in setting option)


Monday, June 21, 2021

Python Settings to use in environments

Solving multiple python instalation:
 
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
sudo update-alternatives --config python3
  

Solving:

Error: Command '['/home/DRIVE/Temp/aa/bin/python3.9', '-Im', 'ensurepip', '--upg
rade', '--default-pip']' returned non-zero exit status 1.
 

apt-get install python3.6-dev python3.6-venv
python3.6 -m venv myVenv 

Upgrade pip

pip3 install --upgrade pip
 

 

Wednesday, March 17, 2021

Python set right version to execute 3.6 3.7 3.8

 

 

https://tech.serhatteker.com/post/2019-12/upgrade-python38-on-ubuntu/

https://stackoverflow.com/questions/63823964/importerror-cannot-import-name-sysconfig-from-distutils-usr-lib-python3-8

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python3 get-pip.py --force-reinstall


ModuleNotFoundError: No module named 'apt_pkg' error
sudo apt-get remove python3-apt
sudo apt-get install python3-apt

 

 


ImportError: No module named OpenGL.GL

apt-get install python3-opengl
or  
pip3 install pyopengl --user

As well as:

sudo apt-get install python python-numpy python-opengl python-qt4 python-qt4-gl

 

 

 

 

Thursday, October 01, 2020

3D Deep Learning

 

https://github.com/mit-han-lab/pvcnn

https://paperswithcode.com/paper/octnet-learning-deep-3d-representations-at


Friday, September 25, 2020

Python Animation Matrix Convolution

 

[1] Convolution animation https://stackoverflow.com/questions/52067833/how-to-plot-an-animated-matrix-in-matplotlib

Wednesday, June 17, 2020

Anisotropic Diffusion


[1] Perona Malik Diffusion for Edge Detection
https://github.com/fubel/PeronaMalikDiffusion/blob/master/main.py

[2] https://github.com/pastapleton/Perona-Malik
[3] https://pastebin.com/sBsPX4Y7

Thursday, March 26, 2020

python pybind11



 for run https://github.com/ilastik/marching_cubes, we need to install pybind11
 alternative to test https://github.com/pmneila/PyMCubes

# prerequisites 
apt-get install cmake
pip3 install pytest

# Clone and build
git clone https://github.com/pybind/pybind11.git 
cd pybind11 
mkdir build 
cd build 
cmake .. 
sudo make install 
 

Thursday, September 12, 2019

SPH on Python

Based on https://pysph.readthedocs.io/en/1.0a1/installation.html
                https://pysph.readthedocs.io/en/latest/installation.html
Examples https://pypi.org/project/PySPH/

python3.2 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
python3 -m venv /path/to/new/virtual/environment
 
 
Object arrays cannot be loaded when allow_pickle=False
pip install numpy==1.16.1
pip3 install PyQt5

 [1] SPH on Python https://github.com/pypr/pysph

Saturday, August 31, 2019

Word cloud

Python codes
[1] https://www.geeksforgeeks.org/generating-word-cloud-python/

Running apps

Runtastic (I uninstalled because force to update your device - Internet connection problems) Runkeeper  (Wrong GPS tracking) Strava   (Curr...