Exporting Python 3.5 and Tkinter to EXE or MSI - python

I'm using Python 3.5 and would like to export my python code for me to send to others who do not have Python installed. Thing is Pyinstaller doesn't work as I get this error:
CX_Freeze also doesn't work for me either as Tkinter still presents a problem, on running python setup.py build I get:
KeyError: 'TCL_LIBRARY'
I'm getting sick of this to be frank so any help would be appreciated. Here's my imports in my code if it helps
import pdb
from tkinter import *
from tkinter import filedialog
import tkinter.messagebox
from datetime import datetime, date, timedelta
import pandas as pd
import numpy as np
from xlsxwriter.utility import xl_rowcol_to_cell

If you are using an older version of cx_Freeze(<5.0), it doesn't have Python35 support. The latest development version has Python35 support. You can install it by
pip install cx-Freeze-win
But you need to have VC++ run-time installed on your system to run this successfully.
Also I've found this GitHub-repo with pre-built binary packages of cx_Freeze 5 for windows platform.
pip install wheel
https://raw.githubusercontent.com/sekrause/cx_Freeze-Wheels/master/cx_Freeze-5.0-cp35-cp35m-win_amd64.whl

Well I managed to get it working by downloading Pyinstaller from the website and running the commands in the new folder. I followed the steps in this answer here.

Related

installed watchdog module .but i am not access the module

while i am using "import watchdog" in python...its showing no module named watchdog....im working in linux (centos)
directory of watchdog module-----'/home/admin/watchdog'
i have tried all the following code
1)
import os
import sys
env=os.path.expanduser(os.path.expandvars('/home/admin/watchdog/src/watchdog/event'))
sys.path.insert(0, env)
import home.admin.watchdog.src.watchdog.event
2)
import sys
sys.path.append('/home/admin/watchdog/src/watchdog/event/')
3)
from home.admin.watchdog.observers import Observer
from home.admin.watchdog.src.watchdog.events import FileSystemEventHandler
4)
PYTHONPATH="${PYTHONPATH}:/home/admin/watchdog/src/watchdog/event/"
export PYTHONPATH
Use PyCharm to write code in python
It helps to solve module errors by itself
It will show hint button when there is an error. So if we press that it will show how to fix or fix it by itsown
You should install watchdog using pip (or pip3) with pip install watchdog (or pip3 install watchdog). This way pip will take care of everything and then you can import it with import watchdog.
Since you have the source you can also go to the base directory and execute pip install -e . or python setup.py install which will both install it such that you can import watchdog with import watchdog.
Finally the proper directory you should include in PYTHONPATH should actually be /home/admin/watchdog/src/.
import sys
sys.path.append('/home/admin/watchdog/src/')
import watchdog.event

cx_Freeze - opencv compatibility

I get a numpy.core.multiarray failed to import error whenever I try to build an exe file using cx_Freeze.
My system uses the following versions:
python 3.6.0
opencv 3.3.0
numpy 1.13.1
cx_Freeze 5.0
The code is:
import cv2
i=333
print(i)
It runs fine (i.e. builds a good exe file) only if I remove the import cv2 line.
Is there any incompatibility between the four modules I listed?
I managed to make this work only after I uninstalled cx_Freeze and installed Pyinstaller instead. It works like a charm.
If this can help you, I managed to make a working example under Linux using SimpleCV with the following configuration:
python 2.7.12
SimpleCV 1.3
numpy 1.11.0
cx_Freeze 5.1.1
The example code cv2_example.py is:
import encodings
import cv2
print cv2.__version__
i = 333
print i
The setup script setup.py is:
from cx_Freeze import setup, Executable
build_exe_options = {'packages': ['numpy']}
exe = Executable(script='cv2_example.py', base=None)
setup(name='cv2_example',
version='1.0',
executables=[exe],
options={'build_exe': build_exe_options})
I guess this example could work also for your configuration with python 3.6.0 and numpy 1.11.0 provided you upgrade cx_Freeze to version 5.1.1.

After a clean install of OpenCV via pip it throws an ImportError: DLL load failed

After installing OpenCV via pip on Windows 10 with:
pip install opencv-python
I can not import the module. When executing the command:
import cv2
I get the error:
File "C:\ProgramData\Anaconda3\lib\site-packages\cv2__init__.py",
line 7, in
from . import cv2
ImportError: DLL load failed:...
If I look into the file throwing the code, it looks like the following:
import sys
import os
# FFMPEG dll is not found on Windows without this
os.environ["PATH"] += os.pathsep + os.path.dirname(os.path.realpath(__file__))
from . import cv2
sys.modules['cv2'] = cv2
So I guess it is ffmpeg which is missing. Thus I installed ffmpeg like described here: http://www.wikihow.com/Install-FFmpeg-on-Windows
Thus, ffmpeg is in my path. However, the error message still occurs. I also tried to install the ffmpeg via pip with
pip install ffmpeg-normalize
But this did not help either.
The opencv-python Windows packages ship with FFmpeg by default. You can have a look at C:\ProgramData\Anaconda3\lib\site-packages\cv2 and you should find FFmpeg DLL there. You don't have to install it separately.
The real problem lies most probably in Anaconda because they are not shipping python3.dll with their distribution. This is required by PEP 384. Related Anaconda issue is here: https://github.com/ContinuumIO/anaconda-issues/issues/1394
To fix this, you will have to copy python3.dll from a CPython installer package and place it to PATH. The CPython version must match your Anaconda version. Easiest way is to copy the file to some place which is already in PATH. This could be for example C:\Anaconda3 if that's where your Anaconda installation is located.
If the above does not work, make sure that you have Visual C++ redistributable 2015 installed: https://www.microsoft.com/en-us/download/details.aspx?id=48145

importing beautiful soup using python 3.6 on OS X

please help!
I am using a macbook running OS X 10.10.5
I am trying to install and then import beautifulsoup using python 3.6 but am getting the following error:
ModuleNotFoundError: No module named ‘beautiful soup’
This is what I have done:
installed python 3.6, this has installed in the applications folder, this is working fine with idle.
downloaded and installed beautifulsoup4, installed using: sudo python setup.py install. This has installed beautifulsoup4-4.5.3-py2.7.egg files into the Library/2.7/site-packages directory
My code is as follows:
import sys
sys.path.append("Macintosh HD/Library/Python/2.7/site-packages")
import beautifulsoup4
Any ideas? Many thanks in advance.
Have you ever checked the documentation of that package?
You import this package as below:
from bs4 import BeautifulSoup

Import BioPython in Spyder Py does not work

I am installed some modules for python, numpy, biopython, mx.. on my mac (10.10.5). I started the Terminal and tried to import them and it works.
After that I installed Spyder, when I try to import bumpy in Spyder it works but biopython (from Bio import *) does not work -> (ImportError: No module named Bio).
also import mx does not works.
If I start Python in the Terminal the import still works.

Categories

Resources