adding auto leveling to linuxCnc

More
26 Jul 2022 10:36 #248314 by andypugh

ImportError: No module named scipy.interpolate


sudo apt-get install python-scipy

Please Log in or Create an account to join the conversation.

More
26 Jul 2022 14:58 #248335 by rajsekhar
Well, python-scipy installed. Thanks Andy for the guidance.

But new error: 
File "./compensation/compensation.py", line 29, in <module>
   from enum import Enum, unique
  ImportError: No module named enum

Out of guess, I run "sudo apt-get install -y enum"; something was installed. I tried enum again, result as per the photo.

But linuxcnc same error persists. What to do??

 
Attachments:

Please Log in or Create an account to join the conversation.

More
26 Jul 2022 16:29 #248346 by andypugh
try

apt-cache search enum

and see if there is a "python-enum" module or similar.

Please Log in or Create an account to join the conversation.

More
27 Jul 2022 02:50 #248384 by rajsekhar
Dear Andy,

python-enum installed.

now a new one in the middle of the way:
ImportError: cannot import name unique

I installed "python-ehenix-mxuid", some thing was autoremoved while installing.
also tried and installed "python-pbs".

But problem not solved. what to do?
Attachments:

Please Log in or Create an account to join the conversation.

More
27 Jul 2022 17:05 #248434 by rajsekhar
Is there any issue with Python version mismatch??

Please Log in or Create an account to join the conversation.

More
28 Jul 2022 04:59 #248506 by rajsekhar
I guess it is enum34 required instead of enum.

But how to install enum34 in linuxcnc2.8.2 wheezy??

sudo apt-get install python-enum34 is not sucessful.

Please Log in or Create an account to join the conversation.

More
28 Jul 2022 15:15 #248549 by rajsekhar
Well, I checked the python version today and it is 2.7.3. Upon help() query in terminal emulator, the module "enum" does not contain any function "unique".
Is this the reason for error??

I have another computer Linuxcnc installed with Buster10 with Python version 2.7.16. and the similar query shows "unique" as function.

Now can I update the Python version from 2.7.3 to 2.7.16? If yes, How?

Please Log in or Create an account to join the conversation.

More
31 Jul 2022 09:56 #248710 by andypugh
I think that this is more of a generic Python question, and you might get further by casting your net wider.

I will observe that this seems a lot to be having to install just for something as simple as autolevelling.

Please Log in or Create an account to join the conversation.

More
25 Aug 2022 10:44 - 25 Aug 2022 20:10 #250394 by ds.lithographie
Hi rajsekhar,

Sorry for responding to your message nearly 2 months late. Haven't got notified for the messages from Linuxcnc forum. I guess I need to configure the notification settings correctly.

What it looks like is a Python specific problem. Python as you might know is a little bit local installation dependent. In my own early days with Python I had a very hard time understanding why "apt-get"-ing python could not really "install" the latest python on Ubuntu. Turns out it had something to do with how your `python` or `python2` command is linked to the specific location in your filesystem. To troubleshoot your situation, I might be looking at the following things:

1. The first line of the python code "#!/usr/bin/env python2" is called a shebang line, and it specifies a specific python interpreter used for executing the code. That is, the "python2" binary from the "/usr/bin/env" folder. You might want to look around /usr/bin/env folder and see what specific python2 binary is installed there. It might be absent or being a lower version than you might expect.

2. check your PATH in the command line console. Do this by using command "echo $PATH" and you will get a string like "/bin:/user/bin:/folder/subfolder:/folder2/subfolder2". This is a search path with the colon symbol ":" serving as separators. The search is performed from the left to right. Say in this example PATH, you have a 2.7.3 python2 in the /bin folder, and a 2.7.16 python2 in the /user/bin folder, and you issue a command "python2". What is going to happen is that python 2.7.3 will be invoked, because it is sitting in the leftmost folder. There are methods to modify PATH. For example, use `alias` or `export PATH=/folder/containing/new/python:$PATH`. Note that these two methods are not permanent, and only last until you exit your current shell. To make the changes permanent, you might need to append a line to your ~/.bashrc, or ~/.bash_profiles file, which gets executed automatically every time you invoke shell.

3. To debug, one thing that might be helpful would be printing out the version of your python interpreter at run-time. do so by inserting `import sys`, and then `print(sys.version)` somewhere in the code, probably at the beginning.

4. To "update Python version", you can try modify the python shebang line, or modify PATH, and then verify result using method described in #3.

5. The "best practice" to deal with python paths is actually using python virtual environments. You can create virtual environment by using "venv", and use the python interpreter from a local venv folder. Note that you might need to install all required packages to run the code after creating a blank slate venv. Note this method is very similar to how I dealt with Java JDK in the "run.sh" script. From the "run.sh" script, "./jdk1.8.0_291/bin/java -jar AutolevellerAE-0.9.5u2.jar", the first argument specifies using the java run-time environment from that specific folder.

6. Going back to the python code itself, Enum and @unique are used in line #33-40, and @unique is really just a good practice property wrapper that prevents you from assigning two Enum's to the same number. Commenting out @unique should not break the code.
Last edit: 25 Aug 2022 20:10 by ds.lithographie.
The following user(s) said Thank You: matti.juntunen

Please Log in or Create an account to join the conversation.

More
14 May 2023 22:55 #271376 by matti.juntunen
I just wanted to reach out and say thank you! I got my autoleveling working thanks to your posts in this thread. I am more of a mechanic than a programmer and need all the help i can get.

It works perfectly fine in metric with FACTOR_UNIT = 1 btw.

I have a question tho. I can only get it working with a 1*1mm grid in probe-results. Would it be possible to get it operating in 2*2? Probing takes so much time with 1*1.

Please Log in or Create an account to join the conversation.

Time to create page: 0.138 seconds
Powered by Kunena Forum