VS Code: Issues setting debugger up in venv - python

I'm following the Python Flask guide from Microsoft, but for whatever reason the debug part is just not working for me. I figured it would be way easier to record a short video showing the error I'm having and also, showing the steps I'm taking.
https://www.loom.com/share/8dfcf53e9c19468ea8a74281931a4fd4
Any help is massively appreciated! The video doesn't have any audio, it's just me showing what I see when setting up a venv into an existing directory and trying to do it from scratch while still having the same issue.
Thanks!
EDIT:
I just noticed I didn't showed the warning itself, it said:
configured debug type 'python' is installed but not supported in this environment.(2)

Related

How to setup python 3.9 on my windows command prompt? It shows an error python not found

I am trying since many hours, after watching several tutorials and reading many blogs I've setup variables as shown by them. Tried all of their methods to setup python3.9 on my windows cmd, but failed. I'm sharing some screenshots of my system variables and other things, please look into the problem and help me.
When you want to share on your post the errors you are getting, please insert them using the Code Sample function so that we can clearly read your errors and have a clear look at your situation.
Anyways, when you first install Python you have to option to automatically add Python to PATH, try uninstalling and checking that option.
If this doesn't work, paste inside your post the error you are getting.
EDIT: Can you share a screenshot of your Python directory?

Getting "Premature end of script headers" on Dreamhost Python Webpage

I have a webpage made in Python Flask with Python 2.7 (I know), hosted on Dreamhost. Up until a few days ago I had absolutely no problems. Then, I started getting a permission error on my page. I don't know what happened, but I got with Dreamhost live chat and they solved it by doing a chmod 755 to my files. Everything was working again, but on further inspection, all the parts that generate a PDF document in my webpage have stopped working. The error that I am getting in the error logs is "Premature end of script headers".
This error only appears whenever I try to generate a PDF. The code works perfectly on my local environment, but it does not work on the hosting. I got with the people of Dreamhost again and they said that it was nothing on their side. Which is weird considering that the code that was ALREADY WORKING was not changed at all. I tried debugging on my part but I am not getting any errors.
I have tried pretty much everything I can think of to solve this situation but I have been unsuccessful. The course of action is to change this hosting (it was a mistake on my part to use Dreamhost in the first place, I know. But when I made this I was just starting and I had very little knowledge). But I need a quicker solution for the moment, and I was wondering if anyone has had this problem and could maybe help me out with this.
To elaborate, I am using Python 2.7, the library that is used for the PDF creation is Flask-Weasyprint (0.5). I tried running the wsgi file myself, and I am getting the following message:
/path/to/local/lib/python2.7/site-packages/WeasyPrint-0.39-py2.7.egg/weasyprint/text.py:29: UserWarning: There are known rendering problems with Cairo <= 1.14.0
warnings.warn('There are known rendering problems with Cairo <= 1.14.0')
/path/to/local/lib/python2.7/site-packages/WeasyPrint-0.39-py2.7.egg/weasyprint/fonts.py:46: UserWarning: #font-face support needs Pango >= 1.38
warnings.warn('#font-face support needs Pango >= 1.38')
I know that I should change to Python 3. When I made this web app, Dreamhost only accepted Python 2 and I barely had any knowledge of creating VPS or something like that. It is my plan to change hosting soon to a virtual machine and to run the project in Python 3. But I need a solution for this now before I go on.
Any help will be appreciated. If you need more details please let me know.
This may be due to the Passenger file not including your project directory in its path. One solution is adding the following to your passenger_wsgi.py file:
sys.path.append(os.getcwd()+"/<project_name>")

Autocompletion in PyCharm not working. I've made sure the intepreter is pointed to my project and I've tried invalidating caches

I remember autocompletion to be working for me on PyCharm some time ago, but I just noticed that is no longer is. It doesn't work for basic python syntax as well as any libraries.
I've tried using the "Invalidate Caches and Restart" option in the File menu of PyCharm. I've also made sure that the Project Interpreter is using the Python in the venv of the project created by PyCharm. I've tried a handful of other things but these two are the most common solutions I've encountered and nothing is working. Note that hitting Ctr-Space anywhere just gives me a "No suggestions" message (not sure if this is relevant but thought I'd mention it).
Any ideas? Any help or ideas at all are appreciated.

Flask mega tutorial part 5 error

Im going through the Microblog tutorial for Flask designed by Miguel.
I made it to part 4 without any issues. Everything ran in the end of part 4.
I started having issues in part 5. After a couple of tries and trying to troubleshoot with the comments in the page, I was not able to finish the exercise.
Thinking it was me, I deleted all of my project and replaced them with the zip downloadable in the page for the exercise. I still get the same error, so the problem is not the code itself.
I get the following error when running views.py:
Link to image on imgur (couldn't post it here due to not having enough reputation)
Here are the libraries I have installed:
Link to image on imgur (couldn't post it here due to not having enough reputation)
My setup:
I am using Pycharm to run the files. This machine runs Windows and I found that Pycharm is the most efficient way to run things without dealing with issues with the cmd line.
Python 3.4
virtualenv created by Pycharm
the code can be found on github: github.com/pdgonzalez872/microblog
Potential cause of the problem:
The problem may be with the path that I have set up (but why did it work until part 4?)
The code itself (maybe something was updated in flask/other libraries since the post?)
views.py isn't meant to be launched separately, there is run.py file to start the project.
Also, it uses relative imports (those with dots before module names), which don't work when you use them in a script passed to the interpreter and used as main. Sorry, I can't explain it well, but maybe you will be interested in those links:
https://docs.python.org/2/tutorial/modules.html#intra-package-references
How to do relative imports in Python?

Python3/MacOSX integration into pycharm

I have had trouble setting up the pycharm ide on my macosx10.7 with python3..
I have scoured every resource available and tried hundreds of approaches, at this point I must accept my incompetence and seek help via this channel.
In my research, I notice a lack of ground-up explanations on python integration into macosx and how to configure pycharm to import modules, run code within the editor, etc. If i ever solve this I will make a very detailed tutorial.
I have imported python3 successfully, it looks like it is linked appropriately from /sys/lib/frameworks to /usr/lib ...etc -- version control is working just fine.
I think my issue is either in setting environmental variables (tried the program to fix this and tried macports) and in the script needed to execute. it will catch errors throughout but final product does not run in python and returns printout of :
/Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2 /Users/anon/Desktop/pythonpractice/Py_Ex/classes.py
Process finished with exit code 0
i really need to get this configuration sound for my python programming class. please help (I've been through every line of pycharm website) .. preferably is there a way to map it via terminal? thanks for anyone who took the time to read this.
Summary of the discussion above:
Python 3.2.2 installation was broken on this Mac, installing ActiveState Python 3.2.2 from scratch and configuring it in PyCharm has fixed the problem.
Python path to be used in PyCharm settings: /Library/Frameworks/Python.framework/Versions/3.2/bin/python3
Incompatible third-party plug-ins may break PyCharm, uninstall/disable them in Preferences | Plugins.
Ensure the latest PyCharm version is installed.
User's code depends on the graphics.py module which was not in the project or in the PYTHONPATH. Putting it into the project has solved the problem.
Most likely the wrong Run/Debug configuration was used in PyCharm, the easiest way to run or debug such scripts is by using the editor context menu Run and Debug actions. PyCharm creates the configuration automatically and debugging works fine as shown of the screenshot:
If one wants to configure and debug it, he can use the code.zip file to get started.
Sorry for the comments mess above, but it was not possible to move it into chat as user had only 1 reputation point, hence not able to use the chat feature of StackOverflow.

Categories