I'm using CLion (2020.2.5) with a mixed project: both C++ and python.
When I load the project from scratch, CLion picks up the CMake files and everything works fine on the C++ side. I get code insights, I can run unit tests etc.
Then I open a python file in my project. CLion suggests I set the python interpreter for the project which I do. Everything on the python side starts working (code insight, unit tests).
But when I do that the C++ side stops working, and I get that warning on every cpp/h file I open:
This file does not belong to any project target, code insight might not work properly
So far the only work around I found is to toggle the python interpreter (to No Interpreter) when I want to do C++.
Related
My vscode can't run any code.I've been trying to fix it for 2-3 days now but that doesn't work.I don't know it about I try to setup c/c++ in vscode about 15 days ago that time it work it can c c++ python however this few day I back to code something and have found can't run any code.
can anyone please suggested solutions.I read previous post about this before but it not the same when I try to run code noting happening and no error.
and about python files must call file like this for run and that file must in Drive C.It unlike normal just press F5 or click runcode then it run.
I want to fix it like before.It mean make it to show the result of my code in visual studio.
If you can't run any code inside VSCode it's most likely the lack of needed extensions causing the problem, you can download extensions by going to the extension menu with ctrl + shift + x and if you are connected to the internet, VSCode will show recommended extensions for you.
About the problem that you can't run a python file outside of the C: drive, I think that the anonymity of your python executor to the CMD is causing this problem.
The easiest way to fix it is to uninstall your python executable with its own installer (the setup.exe file which you installed python with, it can uninstall python too) and installing it again with the difference that you must tick the "add to environment variables" option at the beginning of the installation, then you may be able to run the python executable everywhere with this command:
python example.py
After installing c/c++ extension you might want to go to the extension you downloaded and look under the extension name for other c/c++ extensions you want to install too.
To make intellisense and built-in c/c++ code execution work, download Microsoft's c/c++ extension for the best experience.
May this help you!
Trial 1: Try downgrading your vs-code version and check if problem still persists.
Trial 2: Assuming you don't have code runner, Try installing code runner extension in vs-code and use that for running your program
I'm trying to figure out how can I execute Python code in a C++ program. Where, The C++ program will be a static Executable which will run on systems where python is NOT installed. But it can execute Python code without Python having to be installed on the System it's running on.
I looked onto embedding the python interpreter within my Program. I found this link
Embedding Python in Another Application. But the file Python.h is not found anywhere on my system (Python 3.7). I really need help on this. What can I do to achieve this?
I made an app with Pyqt, which I freezed with Pyinstaller with following options:- (Consider python file name as pyqt_link6.py)
pyi-makespec pyqt_link6.py
pyinstaller --noupx --debug pyqt_link6.spec
Resulting executable launches on my computer and several others (all Windows 7) and functions as expected. However on some machines (same Windows 7 version), it gives following problem:-
(pyqt_link6 is also name of directory where distribution is automatically stored by pyinstaller)
I thought adding --debug option during build was supposed to capture initialization process. But that is not happening.
My main problem is lack of indication of error. What should I look for to correct?
My Python version is 2.7.14 (Anaconda distribution), pyqt 5.6.0, pyinstaller 3.3.1.
I have intentionally not provided any more info, thinking that it may not be necessary and would be like spamming the forum. But should anything more (my python code or spec file be) posted here?. Any indication towards what the problem might be would be helpful.
As some machines can run exe and some can't; what difference should be looked at?
Regards,
My interpreter is the python 2.6 interpreter that comes with cygwin.
I have a pydev project that contains a linked folder.
In the folder, due to outside constraints, I have two sub-folders, one with a bunch of scripts I develop, and one which serves as the run directory for all my run configurations.
When I run the project (not debug) everything works fine.
However, when I choose to debug the project, my custom modules aren't found, and the import fails.
I tried adding my scripts folder to PYTHONPATH, but that didn't help, and when I printed sys.path It contained weird stuff, all of the form:
<path to run directory>/<path to entry in PYTHONPATH>
I can't make heads or tails out of it.
I'll appreciate any help.
Unfortunately, that's a known issue. PyDev does not support Cygwin for debugging. The primary reason is that the paths that Python reports don't match the paths you configure in windows, so, a translation step would be needed for each path (even some other areas such as code-completion or code-analysis could have problems).
You can probably do this translation yourself at eclipse/plugins/org.python.pydev_x.x.x/pysrc/pydevd_file_utils.py (instructions on the file), but note that this may be more work than it's worth (the recommended approach is using a native Python install on Windows instead of through cygwin) -- or if you need an interpreter on Linux, develop on Linux :)
Thanks, you made my day, its actually very easy,
you have to change the PATHS_FROM_ECLIPSE_TO_PYTHON variable inside pydevd_file_utils.py as,
PATHS_FROM_ECLIPSE_TO_PYTHON = [
(r'C:\Users\usernam\workspace-cpp\python-proj\src',
r'/cygdrive/c/Users/usernam/workspace-cpp/python-proj/src')
]
But this needs to be changed for all your own python source files you desire to debug
I am happy to announce a new release of ePyUnit, which solves the load-path issue of 'pydevd.py'. This works from within Eclipse/PyDev as well as from an arbitrary process started from the command line.
ePyUnit now includes the automation of remote debugging with PyDev and Eclipse by 'pydevd.py'. This works seamlessly for the 'subprocess' call as well as independently started command line processes.
See:
https://pypi.python.org/pypi/epyunit
https://pythonhosted.org/epyunit/
For basics of remote debugging:
http://www.pydev.org/manual_adv_remote_debugger.html
Also enhanced unittest integration into PyUnit.
Comments and fixes are welcome.
Have fun...
I have a Python extension that I have successfully built and used on Windows, OSX, and linux. I now need to be able to debug this Python extension. I am averse to the use of gdb at the command line, so I would really like to get this to work in Eclipse.
To begin with, I did my best to follow the instructions in http://www.heikkitoivonen.net/blog/2008/07/21/debugging-python-extension-written-in-c-with-eclipse/, and I added the folder for the Python source as well as the folder for the python extension code as source folders to the empty project. Since it is relatively easy to get debug builds of everything required on linux, I started out with the debug development in Ubuntu.
Once I got a debug build of python (lets call it python_d), I ran the setup.py for my extension with
python_d setup.py build
which should also yield a debug build of the extension module. I have verified that symbols are being exported by opening the extension as an application in Eclipse and I can see the source code linked with the Python shared object.
Now if I create another project in Eclipse with the folder of my code, and add a breakpoint in the source that is used to create the extension, it doesn't stop at the breakpoint. It is entirely possible that I am missing something rather critical here, but for the life of me I can't get it to work. The crux of the problem is:
How can you get Eclipse to stop at a breakpoint in a Python extension module?
Which compiler are you using, MSVC or GCC? For MSVC, you can start python first, and attach the python_d.exe (windbg or visual studio), then you can load your module, setup the breakpoint, you can verify whether your module's symbol got loaded in the debug->module windows (MSVC).