Ubuntu error — cannot import name 'gcd' from 'fractions' - python

I'm using Ubuntu to learn basic bioinformatics. I just downloaded multiqc using conda, but when I want to run multiqc, it returns:
enter image description here
I am very naive and don't know how to solve this problem. ANY help would be highly appreciated. Thanks

I think gcd was moved to the math pack in 3.9. See https://docs.python.org/3/library/fractions.html
Changed in version 3.9: The math.gcd() function is now used to normalize the numerator and denominator. math.gcd() always return a int type. Previously, the GCD type depended on numerator and denominator.
I suggest you create a virtual environment with 3.8 and try that. There are tons of tutorials on how to do this.

As Andrew said, Python 3.8 can be installed virtually. However, I just asked Conda to reinstall the older version of python (3.8), and now it's working perfectly.

This problem happens when you have an outdated version of the networkx package, which is a MultiQC dependency. You can fix it by updating this package:
conda install networkx=2.5.1
The next release of MultiQC (v1.11) will specify that at least this version of networkx is required, to ensure Python 3.9 compatability.
GitHub issue where this was tracked down: https://github.com/ewels/MultiQC/issues/1413

Related

ROS doesn't see numpy

I tried different ways of installation of numpy, but the problem that I'm facing is: there is no **numpy **in the list when I call rospack list-names. Even with installed numpy, when I can see its version and location, ROS still cannot find it and gives me error that no such module is found.
Thank you for answers!
tried installing through different envoronments like pip, pipenv and normally (sudo apt ...).
Maybe there is some way to show ROS where to find a package?
You cannot see numpy as a ROS package because it has no ROS installation procedure at all. Just try to type:
python3
import numpy
If you would see an error, then you need to check numpy is installed on your system. Then you do not have to list it in your package.xml, but you can find the component Python::NumPy in CMakeLists.txt once you have CMake version 3.14 or newer.

Webots using Python 2.7 when Python 3.x is default

On my mac I switched python versions to 3.7 and when using the command python -V in the terminal it shows that it successfully switched. Webots still shows that the deprecated 2.7 version is being used. When I checked the command, it says python
I've messed with creating a runtime.ini as well, which seemed to work but doesn't recognize webot modules like "Controller," or "Robot." Though I can't find anything about what the module names would be and how I could include them in the Options for the runtime.ini with the -m flag.
Any help would be appreciated, thanks
I was able to solve this by setting the absolute path, shown in the image link, to a valid version of Python 3 in the Webots->Preferences command field. I had a slight error with NumPy not coming with this version but was easily fixable by doing <absolute-path-to-version-specified> -m pip install NumPy
I hope this is helpful to others as it was the last thing I tried and cost me some time.
Webots preferences screenshot example

I am receiving and import error when trying to import cv2 in python (Ubuntu 18.04)

First of all, thank you very much for reading.
Some days ago I installed Python3 (3.6.9) and opencv 3.4.10 in an Ubuntu 18.04 desktop system. I needed to downgrade opencv to 3.4.0 after some compilation problems (not related to python3), so I removed opencv 3.4.10 by using the sudo make uninstall order, and tested that it was uninstalled as if I tried importing it in python I got the following error:
libopencv_hfs.so.3.4: cannot open shared object file: no such file or directory
I thought installing 3.4.0 version would solve the problem but now that it's installed, when I try to import it in a python3 script I am getting the same error. I think this error must be related to the way python3 references the import files. I think it's still pointing to the uninstalled version of 3.4.10, but I can not find the way to change it.
Could someone please help me with this issue?
Thank you very much.
Andrés.
Using a virtualenv would resolve the issue. Check this out on how to use : Installing packages using pip and virtual environments
Once you're done installing requirements in the virtualenv, run your python script there only to use the specified versions.
Hello again and thank you for you answers.
I have been able to solve the problem. Thought I had uninstalled the previous version of opencv, there was still a cv2.sofile in my python virtual environment path, and it had not been replaced by the new cv2.so, so python tried to import the old one instead of the new one.
The old cv2.so (the one that was referenced when I imported cv2 in python) was here --> ~/.virtualenvs/cv/lib/python3.6/site-packages/cv2.so
The cv2.so I wanted to be used when imported was here --> /usr/local/lib/python3.6/site-packages/cv2/cv2.so so I replaced the one in the virtual environment path with the one in the lib directory and that did the trick :)

could i re-initilize the sklearn library

http://screencloud.net/v/cPBi
I had problem in importing the sklearn neighbors library (called "LSHForest").
the online example here did exactly the same I did when importing the LSHForest, but mine is not working :(
Not really sure what is possibility wrong. do I have to reinstall ubuntu (because i heared that reinstall python under ubuntu environment is not recommended)
thanks for all the great help
You most likely have an older version of scikit-learn. You can check the current version using:
python -c "import sklearn as sk; print sk.__version__"
If you're using 0.16.1, you should be able to import LSHForest.

ImportError: No module named PyMySQL - issues connecting with Anaconda

so I am new to both programming and Python, but I think I have the issue narrowed down enough to ask a meaningful question.
I am trying to use MySQLdb on my computer. No problem, right? I just enter:
import PyMySQL
PyMySQL.install_as_MySQLdb()
import MySQLdb
At the top of the script.
But here is the problem. I installed Anaconda the other day to try to get access to more stats packages.
As a result, on the command line, "which python" returns:
/Users/vincent/anaconda/bin/python
Based on reading other people's questions and answers, I think the problem is caused by being through Anaconda and not usr/bin/python, but I have no idea if this is correct... I would rather not uninstall Anaconda as I know that is not the right solution.
So, I would like to ask for a very basic list of steps of how fix this if possible.
I am on OSX (10.9) Anaconda is 1.9.1 and I think python is 2.7
Thank you!
You don't need to uninstall anaconda. In your case, Try pip install PyMySql. If which pip return /Users/vincent/anaconda/bin/pip, this should work.

Categories