Difference between revisions of "Python Software installation"

From rbachwiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 14: Line 14:
  py -m pip install pyinstaller
  py -m pip install pyinstaller


<p style="subhead"> add this to you code to fix path issues</p>
<h2 class="subhead"> Add this to you code to fix path issues</h2>


<pre>
<pre>
==[[#top|Back To Top]] - [[Python|Category]]==
def resource_path(relative_path):
[[Category:Python]]
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")
 
    return os.path.join(base_path, relative_path)
</pre>
</pre>
<h2 class="subhead"> Wrap path with function above</h2>
#base_path2 = "C://Users//Dropbox//python//python_desktop//excel//dist//db//"
sqlite3.connect(resource_path(base_path2+'registered.db'))
<h2 class="subhead"> Compile python program into exe</h2>
pyinstaller -name forms --onefile --windowed myfile.py
'''Youtube Video for pyinstaller'''
https://www.youtube.com/watch?v=p3tSLatmGvU&t=303s
==[[#top|Back To Top]] - [[Python|Category]]==
==[[#top|Back To Top]] - [[Python|Category]]==


[[Category:Python]]
[[Category:Python]]

Latest revision as of 20:08, 17 March 2023

Install pandas for data analysis

pip install pandas

Install Jupiter notebook

pip install jupyterlab

Start notebook

jupyter notebook

pyinstaller install and setup

pip install pyinstaller

if that doesn't work

py -m pip install pyinstaller

Add this to you code to fix path issues

def resource_path(relative_path):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")

    return os.path.join(base_path, relative_path)

Wrap path with function above

#base_path2 = "C://Users//Dropbox//python//python_desktop//excel//dist//db//"
sqlite3.connect(resource_path(base_path2+'registered.db'))


Compile python program into exe

pyinstaller -name forms --onefile --windowed myfile.py

Youtube Video for pyinstaller https://www.youtube.com/watch?v=p3tSLatmGvU&t=303s


Back To Top - Category