Python: Difference between revisions

From Smithnet Wiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
On Windows, start pip with:
On Windows, start pip with:
  py -m pip
  py -m pip
== Python Compilation ==
dnf groupinstall 'Development Tools'
dnf install python3-devel
wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
tar xvf Python-3.12.2.tar.xz
./configure --with-ensurepip=install
./configure --enable-optimizations
make
make test
sudo make altinstall
Altinstall does not execute bininstall and maninstall, so good for not overwriting system python. Test resultant binary:
/usr/local/bin/python3.12 --version


== Virtual Environments ==
== Virtual Environments ==
Line 22: Line 38:
Deactivate an env:
Deactivate an env:
  deactivate
  deactivate
== Python Compilation ==
dnf groupinstall 'Development Tools'
dnf install python3-devel
wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
tar xvf Python-3.12.2.tar.xz
./configure --with-ensurepip=install
./configure --enable-optimizations
make
make test
sudo make altinstall
(altinstall does not execute bininstall and maninstall, so good for not overwriting system python)


== Python Installer ==
== Python Installer ==

Revision as of 12:53, 8 April 2024

PIP

On Windows, start pip with:

py -m pip

Python Compilation

dnf groupinstall 'Development Tools'
dnf install python3-devel
wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
tar xvf Python-3.12.2.tar.xz
./configure --with-ensurepip=install
./configure --enable-optimizations
make
make test
sudo make altinstall

Altinstall does not execute bininstall and maninstall, so good for not overwriting system python. Test resultant binary:

/usr/local/bin/python3.12 --version

Virtual Environments

Create a virtual environment:

python -m venv py-env/demo

Activate a virtual environment on Windows:

py-env\demo\Scripts\activate

or Linux:

. py-env/demo/bin/activate

Install within a venv:

pip install --upgrade pip
python -m pip install pyinstaller
python -m pip install requests==2.6.0

Deactivate an env:

deactivate

Python Installer

pip install pyinstaller

Add C:\Users\<user>\AppData\Roaming\Python\Python312\Scripts to PATH:

pyinstaller --onefile file.py

and the resultant executable will be in the dist directory.