python AttributeError: module 'math' has no attribute 'comb' - math

I'm getting an error when I try to use the 'comb' function:
$ python
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> print(math.comb(6,49))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'math' has no attribute 'comb'
>>>

The comb function is new in Python 3.8 (see documentation here). Your Python installation is 3.7.1. If you update your Python installation, the issue should be resolved.

Related

Pip install error and Setuptools.command not found

I was using the guide in this link to install a package in a specific conda environment: https://github.com/alegiac95/Imaging-transcriptomics. However, I was unable to do so and had the following error. Would really appreciate the help!
Traceback (most recent call last):
File "setup.py", line 9, in
from setuptools import setup, find_packages
ImportError: No module named 'setuptools'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 11, in
from distutils.core import setup, find_packages
ImportError: cannot import name 'find_packages'

R Reticulate: ModuleNotFoundError: No module named 'pandas'

I am using the Azure ML Notebook with R kernel to use a python script through reticulate package but I am unable to install pandas library which is using in the python script. I am following the instructions from here. I have written the following R code:
library(reticulate)
Sys.which("python")
use_python("/usr/bin/python3.8")
When I use py_config() then it gives me the following output:
python: /usr/bin/python3.8
libpython: /usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so
pythonhome: //usr://usr
version: 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
numpy: [NOT FOUND]
Now, conda_list() shows the r-reticulate environment and its location as /anaconda/envs/r-reticulate/bin/python and when I try to install pandas in default r-reticulate environment using:
conda_install("r-reticulate", "pandas")
Then it gives the following output:
+ '/anaconda/bin/conda' 'install' '--yes' '--name' 'r-reticulate' '-c' 'conda-forge' 'pandas'
But when I use pandas <- import("pandas") then it gives me the following error message:
Error in py_module_import(module, convert = convert): ModuleNotFoundError: No module named 'pandas'
Can anyone please tell me whether this is issue related to path or something else and how to fix it.
Any help would be appreciated.
Not sure what the problem is, but have you tried
reticulate::py_install('pandas', pip = TRUE)

PyQt built on Windows: DLL load failed: The specified procedure could not be found

I've tried to build PyQt from sources (with binary Qt 5.8.0 downloaded) on my Windows 7x64.
I did it by this tutorial: https://stackoverflow.com/a/40779370/2726900
I've entered Visual Studio 2015 Command Prompt, activated vcvarsall.bat amd64, activated qtenv2.bat.
Than I configured, built and installed SIP (no errors).
Than I configured PyQt (just added --sip C:/Python35/sip.exe) and successfully built and installed PyQt.
The filed like QtCore.pyi, QtCore.pyd, QtGui.pyi, QtGui.pyd and so on really appeared in my site-packages/PyQt5 folder.
Bug when I tried to import some modules from my installed PyQt5, it failed.
>>> from PyQt5 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
Cannot you tell me, how can I fix it?
python -m pip install --upgrade pyqt5

Python3, Rpy2 and R 3.1.1 ImportError undefined symbol

I used pip and installed RPy2 on my raspberry Pi 3 running Raspbian Jessie. I have a working installation of R 3.1.1 (tried upgrading to a newer version but couldn't seem to make it work). I get a strange error when I try to run python3 -m rpy2.tests. I get the following error:
$ python3 -m rpy2.tests
Traceback (most recent call last):
File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.4/dist-packages/rpy2/tests.py", line 23, in
<module>
import rpy2.tests_rpy_classic
File "/usr/local/lib/python3.4/dist-packages/rpy2/tests_rpy_classic.py",
line 3, in <module>
import rpy2.rpy_classic as rpy
File "/usr/local/lib/python3.4/dist-packages/rpy2/rpy_classic.py", line 5,
in <module>
import rpy2.rinterface as ri
File "/usr/local/lib/python3.4/dist-packages/rpy2/rinterface/__init__.py",
line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /usr/local/lib/python3.4/dist-
packages/rpy2/rinterface/_rinterface.cpython-34m.so: undefined symbol:
installChar
Can anyone point me to what I need to do to fix this?
Thanks!
I also had the same error: it ended up being due to the version of R (3.1.0 or 3.2.0).
Updating to R 3.4.0 fixed it.

rpy2 module not working in Python3.2

I am trying to import the rpy2 (version2.3.4) library into Python (version3.2.3) on a Ubuntu 12.10 machine. The rpy2 documentation says that rpy2 works under all Python 3 versions and I am also finding other topics related to rpy2 and Python3.2 which show that these versions should work together. Anyhow when I try to import a module:
from rpy2 import robjects
the result is this:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/__init__.py", line 14, in <module>
import rpy2.rinterface as rinterface
File "/usr/local/lib/python3.2/dist-packages/rpy2/rinterface/__init__.py", line 8, in <module>
raise RuntimeError("Python (>=2.7 and < 3.0) or >=3.3 are required to run rpy2")
RuntimeError: Python (>=2.7 and < 3.0) or >=3.3 are required to run rpy2
So, is rpy2 really not working with Python3.2 what would fit to the information the projects is giving me or waht might be the problem.
thx.
The rpy2 documentation says that rpy2 works under all Python 3 versions
Not quite, I hope; check the part about installing rpy2.
Python 3.2 will probably never be supported by rpy2 (Python 3.2 is already EOL). If your are after using Python 3, update to Python 3.3.

Resources