Launching CloudComPy in VS code
Hello,
Sorry if this is a trivial question, but I am having trouble installing cloudComPy in VS code and would like to get a handle on how to troubleshoot it. Yesterday, downloaded the Windows binary (i.e., CloudComPy310_20240927), and worked my way through the installation code. The envCloudComPy.bat worked (python test: import cloudComPy & Environment OK!) and the ctest ran successful (57/58 test ran successful, while the 1 test [test50.py] was determined to be ok to ignore). Today, I want to start writing code in python using cloudComPy (in VS code). I open VS code and select the python interpreter to be the environment created yesterday (i.e., form the code: conda create -y --name CloudComPy310 python=3.10), but I get the following message when I run import cloudComPy as cc, "ModuleNotFoundError: No module named "cloudComPy".
Is there a step that I am missing?
Thanks, Luke
Hello,
Have you tried running VS code from the conda console with the CloudComPy310 environment, after envCloudComPy.bat?
If VS code has been added to the path, just type code, otherwise you need to give the full path...
Paul
Hi Paul,
It worked! I opened a new Anaconda Prompt today and typed
-
conda activate CloudComPy310 -
cd <path_to_CloudComPy310> -
envCloudComPy.bat -
code(after verifying that I had it by typingcode --version; output 1.96.2)
VS code was executed (via Anaconda Prompt) and I was able to run import cloudComPy as cc, and some of the following code on the README. Just to confirm - every time I want to work with cloudComPy in VS code, these steps are how I will initial it each time?
Thanks, Luke
Hi Luke,
Yes, I think you'll have to initiate the CloudComPy environment this way every time. There may be other ways of defining the environment without having to go through all these steps every time. One possibility is to write a .bat script to do all this...
Paul
For what it's worth, @L-Gregory I wrote a batch script to do this for code I'm running as one step in a longer process. Maybe this can help?
@echo off
:: Step 1. Get the conda env path for CloudComPy
for /f "usebackq tokens=1,2" %%a in (`conda info --envs ^| findstr /c:"CloudComPy"`) do @set condaPath=%%b
@echo This is the envpath: %condaPath%
:: Step 2. Activate the conda environment
call activate %condaPath%
:: Step 3. Check the env is correct and the paths are set
:: If this throws an error, then need to look at the variables in
:: `CloudComPy310/envCloudComPy.bat` for troubleshooting
call CloudComPy310\envCloudComPy.bat
:: Step 4. Call the python script to run through the processing.
:: If this doesn't work, test this with the basic python script
:: below saved as "scripts/testDelete.py"
python scripts/cloudCompare/2_runCC.py %1 %2 %3 %4 %5 %6
:: Step 5. Deactivate conda environment
call conda deactivate
Hi Paul,
It worked! I opened a new Anaconda Prompt today and typed
conda activate CloudComPy310cd <path_to_CloudComPy310>envCloudComPy.batcode(after verifying that I had it by typingcode --version; output 1.96.2)VS code was executed (via Anaconda Prompt) and I was able to run
import cloudComPy as cc, and some of the following code on the README. Just to confirm - every time I want to work with cloudComPy in VS code, these steps are how I will initial it each time?Thanks, Luke
Hi!!! I encountered the same problem. After reading your sharing, I am now able to import and use it correctly in Anaconda prompt. But when I entered the code in the prompt to open VSCode, although the environment of VSCode was correct (cloudcompy310), I couldn't import and use it anymore. Have you encountered any problems in the future?
Hi @Waydelucien,
For the times that my computer restarts or shuts off - I have to open a new Anaconda Prompt and type in all four steps from above (i.e., conda activate CloudComPy310, cd <path_to_CloudComPy310>, envCloudComPy.bat, code (which loads VS code)). Once in VScode, I set my python environment to be the CloudComPy310. Once set I can then run import cloudComPy as cc and cc.initCC()
I have never had a problem using cloudComPy if I follow the steps above, it is only when I deviate from it (i.e., if I just open the Anaconda prompt and run code, but not anything else) that I will not be able to import cloudComPy correctly.
Best, Luke
Hi @Waydelucien,
For the times that my computer restarts or shuts off - I have to open a new Anaconda Prompt and type in all four steps from above (i.e., conda activate CloudComPy310, cd <path_to_CloudComPy310>, envCloudComPy.bat, code (which loads VS code)). Once in VScode, I set my python environment to be the CloudComPy310. Once set I can then run
import cloudComPy as ccandcc.initCC()I have never had a problem using cloudComPy if I follow the steps above, it is only when I deviate from it (i.e., if I just open the Anaconda prompt and run code, but not anything else) that I will not be able to import cloudComPy correctly.
Best, Luke
Thank you for your prompt response! After trying a few times, I found that finally I can open VSCode in anaconda prompt to import cloudcompy. I don't know where the mistake went before. Anyway, thank you!!! I hope your research progresses smoothly!