Basic Python Project Setup
Basic project setup
- Create a project folder:
touch myproj
- Decide if you need a virtualenv. If you do run:
$ pyenv virtualenv 3.10.3 myProj
to install using default pyenv run:
pyenv virtualenv myProj
- Create .python-version file:
# This creates and activates the virtualenv when you are in the directory pyenv local myProj
- Install Pylint and generate config file.
# install pylint and black. Black isn't needed for sublime-black to work. pip install pylint black # generate .pylintrc which lets you chage settings. pylint --generate-rcfile > .pylintrc
- Install other packages as needed
- Open
myProj
folder in Sublime - Save project as
myProj.sublime-project
. This creates a project file that will open up the entire project all at once. And if you have side bar installed you can navigate between files easily. - Command palette: LSP-Pyright: Create configuration file. This makes a pyrightconfig.json file. You can specify what pyenv version pyright uses
{ // Install LSP-json to get validation and autocompletion in this file. "venvPath": "/Users/username/.pyenv/versions", "venv": "myProj", }
- At this point these things should be set up
- pyenv
- pyright
- pylint
- sublime
- folder structure