![]() Postman allows us to make requests to our venv via that IP address, and use different restful methods. If we copy the IP address, load Postman we can get started. Once that's done a new terminal box will open and you will be greeted by an IP address that we can use in Postman. So let's code! The first thing we need to do is tell Python to use Flask, so at the top of our main.py we need to add the following lineĪt the top of P圜harm you will see a green play button, if you press that it will spin up our venv (Virtual Environment) This will allow us to connect to our API. When that's finished close the settings box and we are ready to code. So if you click the plus button you will be greeted with a list and search box, type flask, and press install package. Inside there click the arrow next to Project:ProjectName and inside there you will see Python Interpreter, click on that and you will be shown all the packages installed with this project. If you press ctrl+alt+s you will open P圜harm's settings. So with no text in that file let's install flask. Now we have a new main.py file we should start by deleting everything in it and start from a blank file. ![]() So we want to accept the new virtual environment and click create, this will choose the newly installed python as our interpreter and create a brand new project which we can start and debug in real-time - But more on that later! Here we are going to set up a new virtual environment, for those new to Python like me a virtual environment is a Python environment that the Python interpreter, libraries, and scripts are installed into, they are also isolated from those installed in other virtual environments. When you first start P圜harm it will offer you the choice to open an existing project or start a new one, so let's go with a brand new one and the next screen is the important one. Now we have everything ready let's start up P圜harm and get a simple endpoint created and some data flowing. We will have fun with P圜harm in this series and enjoy the Python rich environment it offers! So head over to and grab the link and get downloading.Īnd last but certainly not least lets grab Postman! For me, P圜harm simply makes this whole process easier. ![]() Now there is Visual Studio Code which is free to download and enjoy and if you feel more comfortable with installing pip packages and setting up virtual environments then please go ahead and use that. That's the first part taken care of and now onto the IDE, and IDE stands for an integrated development environment. Run the command again and we are good to go. If you have any other message or an error head over to and download and install. You should get an output that looks like the following: I am starting to run out of ideas what else I could check and hope someone can give me a hint.Enter fullscreen mode Exit fullscreen mode Test the environment with vscode (everything works as expected).Check my file system permissions (my user can read and write everything).Check my project and Python file name (no collisions here).Create a project directory virtual environment using pipenv outside of P圜harm (it worked, but did not fix the import).Create a new project with pipenv and virtualenv.This issue only affects Flask, other modules and their classes can be imported. Visual Studio Code doesn't have any issues with the module, even when I use the same project and virtual environment. The code runs fine, I can execute it using the the flask executable or the genererated run configuration. But it seems it cannot find the Flask class. P圜harm finds the module flask just fine, it even suggests it and displays the correct path of the _init_.py file when I hover over it. I have a rather specific issue when trying import flask into my project using the typical syntax: from flask import Flask
0 Comments
Leave a Reply. |