I've never used Ubunts, and I got into Hyper-V from the beginning. From there, I got various information as to whether there are not many opportunities to exeize python in the world, but I will summarize it because I was able to exe.
environment windows10 64bit ubunts 20.04 python 3.7.7 pip 20.2.4 pyenv version 2020.11.15 pyinstaller 4.0
-Run Ubuntu on Hyper-V on Windows 10 -I think that there is no problem in building ubunts if you look at this article and build it. You will need to set the'network adapter'to the new virtual switch later in the network settings in the virtual machine settings created by Hyper-V Manager.
sudo apt update
sudo apt upgrade
sudo apt install -y build-essential # c ++ compiler sudo apt install -y libffi-dev sudo apt install -y libssl-dev # openssl sudo apt install -y zlib1g-dev sudo apt install -y liblzma-dev sudo apt install -y libbz2-dev libreadline-dev libsqlite3-dev # bz2, readline, sqlite3 sudo apt install -y git
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
pyenv install 3.7.7
echo "3.7.7" > .python-version
pip install pipenv
WARNING: You are using pip version 19.2.3, however version 20.2.4 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
I think this guy will come out
pip install --upgrade pip
pipenv install
When developing with Python, a tool that easily and automatically manages packages for each project and builds a virtual environment. You can use pip to install packages and virtualenv (venv) to build virtual environments, but pipenv supports them so that they can be handled more easily.
Using /usr/bin/python3.8 to create virtualenv ・ ・ ・
×Failed creating virtual enviroment In my case I got the above error. It seems that the Python version is different
pipenv --python 3.7
You have now specified the Python version to use.
pipenv shell
I put it in a virtual environment
pipenv install argparse
pipenv install argparse==1.4.*
cat Pipfile
pip install pyinstaller
pipenv install pyinstaller
Move to the directory where the file you want to exe exists,
LD_LIBRARY_PATH=/home/namae/.pyenv/bin/pyenv pyinstaller test.py
This caused an error.
OSError: Python library not found: libpython3.7m.so.1.0 libpython3.7mu.so.1.0 libpython3.7.so.1.0 libpython3.7m.so
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
** Occurs when pyenv install is done without setting the --enable-shared option in the environment variable PYTHON_CONFIGURE_OPTS. ** **
LD_LIBRARY_PATH=/home/namae/.pyenv/versions/3.7.7 pyenv install
LD_LIBRARY_PATH=/home/namae/.pyenv/versions/3.7.7 pyinstaller test.py --onefile
Building EXE from EXE-00.toc completes successfully.
The exe is ready! !!
cd dist
./test
hello
It's running, OK!
There is a big problem with the folder The file I want to exe is so big (although it was about 12MB) It's done.
__ Referenced article __
--__ Environment construction with Debian + anyenv (pyenv) + pipenv __ --__ Notes on making it executable with Pyinstaller __
--__ Talk about installing pyenv on ubuntu 20.04 [Updated on 2020/07/18] __
Recommended Posts