0

I am working on a Python code embedding in c++ helloworld program, necessary additional include/library directories are properly set up. Now I have made it work using the answer from

python works in c++ in debug mode, but not in exe file

I hope my code works on my teamates' PC. What I did was

[1] copy folder C:/Python to D:/Project/Python

[2] retrieve Python registry file, replace C:/Python/... by D:/Project/Python/..., and save a new registry file ProjPython.reg

[3] let my teamate save my project to D:/Project/Python and run ProjPython.reg

This is clearly very stupid, I think what it needs is just telling Visual Studio the directories of Python header, interpreter, dll and so on.

Then I searched it online, finding that I could use Python Environments in Visual Studio (i.e. Python Tool Visual Studio).

After I set up Prefix Path, Interpreter Path, Windowed Interpreter to D:/Project/Python D:/Project/Python/python.exe D:/Project/Python/pythonw.exe, hoping it would run successfully without editting registry, but it failed.

Anybody know how to set up Python directories in Visual Studio 2017 and later for C++ code that containing some python scripts. Gracias!

Tiger Hu
  • 47
  • 7
  • I sense that you are confusing Visual Studio (the development environment) and MSVC (the C++ compiler that build executables). This is an understandable confusion if you come from Python, which really is an interpreted language. The problem is, EXE files are stand-alone and generally should run on machines which do not have Visual Studio installed. – MSalters Mar 04 '19 at 09:19
  • @MSalters Gracias for pointing it out. As long as necessary .dll .py and other files put in a same folder with .exe, it should work on any PC. Also I am working with a team, someone does not have Python installed, someone has different Python version, so I am hoping my team could use a unified Python (without affecting their own Python environment) – Tiger Hu Mar 04 '19 at 09:47
  • You can have multiple Python installations on Windows, including different versions and furthermore you can have separate Python virtual environments for each project. – ElmoVanKielmo Mar 04 '19 at 10:12

0 Answers0