04-24-2019, 04:38 PM
Hello, is it possible to set the python environment to Virtual environment in the RoboDK?
Virtual Environment |
04-24-2019, 04:38 PM
Hello, is it possible to set the python environment to Virtual environment in the RoboDK?
04-25-2019, 10:38 AM
RoboDK automatically includes the RoboDK/Python folder as the python path (PYTHONPATH variable) when you launch a Python program from RoboDK. You can place any dependencies there.
If you want to create different environments it may be better to setup a separate projects (for example, using VSCode or PyCharm) and install the RoboDK API for Python on your preferred Python version: https://pypi.org/project/robodk/ The RoboDK API also works when you launch it externally (not using RoboDK).
01-30-2024, 12:24 PM
(04-25-2019, 10:38 AM)Albert Wrote: RoboDK automatically includes the RoboDK/Python folder as the python path (PYTHONPATH variable) when you launch a Python program from RoboDK. You can place any dependencies there. Hello, thanks for your sharing. I’m new to using RoboDK, and I have a question about using python with RoboDK. I have built a python virtual environment in another folder, and I have installed RoboDK library by pip in my virtual environment. However, when I want to import 3rd part library included in my virtual environment through the python program created in RoboDK software, I got a mistake "Fail to import "File "C:/Users/Appdata/Temp/Prog1.py, no module 'desired library name'". So, I want to know how to manage the python environment of RoboDK software, or how to import 3rd part library.
01-30-2024, 02:05 PM
(01-30-2024, 12:24 PM)Zhang Guoquan Wrote:(04-25-2019, 10:38 AM)Albert Wrote: RoboDK automatically includes the RoboDK/Python folder as the python path (PYTHONPATH variable) when you launch a Python program from RoboDK. You can place any dependencies there. Hello, Albert. I tested some different codes and libraries, and I found that RoboDK seemed to use the Anaconda base environment. So, if I want to use some new library, do I have to install it in the base environment? Besides, for example, when we use python in pycharm, we may create some .py files and import them in another file, which are all placed in the same folder. I don't know how to achieve this behavior, so I tried to add some files in folder of 'Macros', naturally, I failed to import these files in a python program created in RoboDK software. Can I only define this code as a function and add it to the python program created in RoboDK? I don't know if I‘m right, hope for your reply. Regards, Guoquan Zhang
01-30-2024, 03:59 PM
(01-30-2024, 02:05 PM)Zhang Guoquan Wrote:(01-30-2024, 12:24 PM)Zhang Guoquan Wrote:(04-25-2019, 10:38 AM)Albert Wrote: RoboDK automatically includes the RoboDK/Python folder as the python path (PYTHONPATH variable) when you launch a Python program from RoboDK. You can place any dependencies there. Hello, Albert. Please ignore these previous messages, I made some mistakes. Now I know that I can add my own Python module into the folder of 'RoboDK/python'. So in conclusion, I have three questions, could you help me? 1. If I want to pip install a 3rd library, which environment I should operate? 2. If I used the Python interpreter installed for my virtual environment, if it influence the Python environment RoboDK software used? 3. I also installed robodk library in my virtual environment, I can import it in a .py file in my virtual environment, but I don't know if this import can link with RoboDK software. Regards. Thanks, Guoquan Zhang
01-31-2024, 12:46 PM
You can easily install Python packages by following these steps:
You can use your own custom Python version and environment as well and the RoboDK API will still work.
01-31-2024, 02:53 PM
(01-31-2024, 12:46 PM)Albert Wrote: You can easily install Python packages by following these steps:Hello, Albert. Thanks for your help! I don't know if I understand correctly. No matter which Python interpreter I use (embedded or my created environment), I can always call the Python libraries installed under the folders RoboDK/python and RoboDK/python_embeded, so if I want to install a package just for RoboDK, Just install it to the path RoboDK/python or RoboDK/python_embeded. Regards Guoquan ZHANG
02-01-2024, 08:46 AM
When you run scripts from RoboDK software, RoboDK will use RoboDK/Python as the PYTHONPATH. If you call Python scripts from your own version of Python you'll use the default settings for that version of Python.
02-02-2024, 02:01 AM
|
Users browsing this thread: |
1 Guest(s) |