Fail to import avro schema with python3.6.4 - python-3.x

from python prompt:
>>> import avro
>>> import avro.schema
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'avro.schema'
>>> print(avro)
<module 'avro' (namespace)>
>>> print(avro.schema)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'avro' has no attribute 'schema'
specs:
deb9 x64, Python 3.6.4 and avro-python3 Version: 1.8.2, pip 9.0.1
virtualenv activated and avro got pip installed
is avro maintained or should i use fastavro, how to solve above, cant run basic examples from quickstart

Check your requirements.
It might be avro==1.8.2
The above error was coming for this requirement.
Changing the requirement to:
avro-python3==1.8.2 solved the problem for me.
Used pip install avro-python3 instead of pip install avro

Related

'Invalid syntax' error when importing torch (Linux)

I'm trying to install torch under miniconda and simple import torch gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/__init__.py", line 779, in <module>
from .serialization import save, load
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 18, in <module>
from typing_extensions import TypeAlias
File "/home/username/.local/lib/python3.8/site-packages/typing_extensions.py", line 880
if stripped_args
Interestingly, if I repeat import torch again the error message changes:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/__init__.py", line 249, in <module>
for name in dir(_C):
NameError: name '_C' is not defined
I'm not using notebooks, python version is 3.8.16, pytorch version is 1.13.1. Miniconda is installed in a local folder (it's a university server so I can only do it like this due to disk space restrictions), the server runs on Ubuntu.
What could possibly be the problem?
The only recommendation I found for similar problems is to install Cython but it didn't help.
Downgraded to python 3.6 and this somehow solved the problem.

Cannot import installed python package (MacOS)

I cannot import any python package when running python on Visual Studio code or on my Terminal. I can still do this if I were to code on a Jupyter notebook. However, when I tried other environment that doesn't use the notebook server. It returns me ModuleNotFound Error like this
Traceback (most recent call last):
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/test_PreprocessText.py", line 1, in <module>
import PreprocessText
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/PreprocessText.py", line 1, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Most of my packages was download via anaconda. I don't know if it might be the cause of this.

Pandas not working: DataFrameGroupBy ; PanelGroupBy

I have just upgraded python and I cannot get pandas to run properly, please see below. Nothing appears to work.
Traceback (most recent call last): File
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/_tqdm.py",
line 613, in pandas
from pandas.core.groupby.groupby import DataFrameGroupBy, \ ImportError: cannot import name 'DataFrameGroupBy' from
'pandas.core.groupby.groupby'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/groupby/groupby.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"code/analysis/get_cost_matrix.py", line 23, in
tqdm.pandas() # Gives us nice progress bars File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/_tqdm.py",
line 616, in pandas
from pandas.core.groupby import DataFrameGroupBy, \ ImportError: cannot import name 'PanelGroupBy' from 'pandas.core.groupby'
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/groupby/init.py)
I guess you are using an older version of tqdm. Try using a version above tqdm>=4.23.4.
The command using pip would be,
pip install tqdm --upgrade
The problem is with the 0.25.1 version of pandas. Consider downgrading it to 0.24.0.
For more information read this
pip install --upgrade pandas==0.24.0

How to deal with "ModuleNotFoundError: No module named 'setup' "

I installed the module "pyunicorn" in Ubuntu 16.04 LTS and all the dependencies but when I import the module in python 3.7.3 i get this error :
>>> import pyunicorn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda3/lib/python3.7/site-packages/pyunicorn/__init__.py", line 43, in <module>
from setup import __version__
ModuleNotFoundError: No module named 'setup'
What should i do to make it run properly???
I had this problem. I wanted to install it on Google Colab. I tried installing pyunicorn directly from Github and it worked for me. Try using following instruction:
pip install git+https://github.com/pik-copan/pyunicorn.git#egg=pyunicorn

import rpy2.ipython meet error ModuleNotFoundError: No module named 'IPython'

My python version is 3.6. my OS is windows. After install rpy2 module, when I type import rpy2, got no issue. But when type import rpy2.ipython, got error as below:
>>> import rpy2.ipython
Warning (from warnings module):
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 76
"either.")))
UserWarning: The Python package 'pandas' is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded, and we did not manage to load 'numpy' either.
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import rpy2.ipython
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 81, in <module>
from IPython.core.displaypub import publish_display_data
ModuleNotFoundError: No module named 'IPython'
Can help to figure out what's issue??
It seems that you are missing Ipython and pandas. Installing them should resolve your issue.
Run "pip install ipython" to install Ipython and run "pip install pandas" to install pandas.
Hopefully, this will solve your problem.
Happy Coding ~

Resources