Patrick
Posted on August 5, 2020
Only use Poetry - no strings attached
The web shows you multiple solutions to get you going in python and many are used in conjunction with other environment setup dependencies even if they don't have to.
💡 Use Poetry!
First of all, we assume that you are not working in a docker environment and you are using Poetry for pure development purposes. Moreover, the Python installation should be performed after considering advice on Python's official website. For instance, following this Link you can find the installation instructions for Python 3.8 for Mac.
For this solution, you don't need any of the other tools 🔧 such as:
- pip
- pipenv
- pipx
- virtualenv
Why would you use Poetry?
Interdependencies issues can be avoided, i.e. a new dependency requiring dependencies will not break your application. Pip refers to specific versions and hence poses this problem. Pip is the straight forward answer if you are about to deploy and not develop the application any further, however. 🚀
The other listed too tools are not required to run Poetry.
💡 If you face issues with Poetry, do not mix other solutions into your development environment.
Install Poetry and initialize project
The installation works by executing the official installation Script with your python3.8:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
💡 Notice that you need to use python3 or python3.8 depending on your installation. 😞 If you simply use python, your setup will be based on your python2 environment.
😠Don't follow the advice of people who ask you to set up an alias for your python command in your bash/zsh shell. This may break other programs that you use.
Starting a new project 🎉
The best way is to create the folder yourself and use Poetry's interactive mode to generate a pyproject.toml file that is your 2020 replacement for your requirements.txt file:
poetry init
Activating the environment
To activate the environment you need to use the following command:
poetry shell
The virtual environments are centrally stored and not mixed into your project. So you don't need to worry about your .gitignore file anymore for a venv folder. You can alternatively use different environments.
poetry env use python3.7
Troubleshooting Poetry for selecting the environment
For Mac users I recommend updating Poetry to the latest version as the environment may not be activated properly. Again, you don't need to use any other dependencies. The point is to avoid unnecessary dependencies, right?
poetry self update --preview
More information on the described bug 👉 here.
Posted on August 5, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.