Macbook M1 import errors with jupyter notebook

Viewed 721

I just got a new Macbook with a M1 chip. I managed to install python version 3.7.12 and wanted to continue working on a jupyter notebook I created on my old Mac. Hereby, I came across the issue that after I imported all the relevant packages in the first cell, these imports were not found in the next cell (see below).

To reproduce:

  1. Imports
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler, LabelEncoder
from keras.models import Sequential
  1. Check Import
test_df = pd.DataFrame()
  1. See Output (the following for me)
NameError: name 'pd' is not defined

I already read about and tried the issue of dying kernels (https://github.com/jupyter/notebook/issues/5882). Interestingly, when playing with the sequence of the imports, I realized that the keras import seems to be the problem.

To reproduce:

  1. import pandas as pd
  2. test_df = pd.DataFrame()
  3. from keras.layers import Dense
  4. test_df = pd.DataFrame()

Here, I obersed that cell 2 works just fine, but cell 4 (after the keras imports) again returns "the NameError: name 'pd' is not defined" error. For now, as a workaround, I just changed the sequence of my imports and split it into different cells.

This is my first question on StackOverflow, so if any information is missing, please let me know. Thanks in advance for any help!

Pip list:

absl-py                      1.0.0
appnope                      0.1.2
argcomplete                  1.12.3
argon2-cffi                  21.1.0
astunparse                   1.6.3
attrs                        21.2.0
awscli                       1.22.14
backcall                     0.2.0
bleach                       4.1.0
boto3                        1.20.14
botocore                     1.23.14
cached-property              1.5.2
cachetools                   4.2.4
certifi                      2021.10.8
cffi                         1.15.0
charset-normalizer           2.0.8
colorama                     0.4.3
debugpy                      1.5.1
decorator                    5.1.0
defusedxml                   0.7.1
docutils                     0.15.2
entrypoints                  0.3
flatbuffers                  2.0
gast                         0.4.0
google-auth                  2.3.3
google-auth-oauthlib         0.4.6
google-pasta                 0.2.0
grpcio                       1.42.0
h5py                         3.6.0
idna                         3.3
importlib-metadata           4.8.2
importlib-resources          5.4.0
ipykernel                    6.5.1
ipython                      7.30.0
ipython-genutils             0.2.0
ipywidgets                   7.6.5
jedi                         0.18.1
Jinja2                       3.0.3
jmespath                     0.10.0
joblib                       1.1.0
jsonschema                   4.2.1
jupyter                      1.0.0
jupyter-client               7.1.0
jupyter-console              6.4.0
jupyter-core                 4.9.1
jupyterlab-pygments          0.1.2
jupyterlab-widgets           1.0.2
keras                        2.7.0
Keras-Preprocessing          1.1.2
libclang                     12.0.0
Markdown                     3.3.6
MarkupSafe                   2.0.1
matplotlib-inline            0.1.3
mistune                      0.8.4
nbclient                     0.5.9
nbconvert                    6.3.0
nbformat                     5.1.3
nest-asyncio                 1.5.1
notebook                     6.4.6
numpy                        1.21.4
oauthlib                     3.1.1
opt-einsum                   3.3.0
packaging                    21.3
pandas                       1.3.4
pandocfilters                1.5.0
parso                        0.8.2
pexpect                      4.8.0
pickleshare                  0.7.5
pip                          21.3.1
prometheus-client            0.12.0
prompt-toolkit               3.0.23
protobuf                     3.19.1
psycopg2-binary              2.9.2
ptyprocess                   0.7.0
PuLP                         2.5.1
pyasn1                       0.4.8
pyasn1-modules               0.2.8
pyathena                     2.3.1
pycparser                    2.21
Pygments                     2.10.0
pyparsing                    3.0.6
pyrsistent                   0.18.0
python-dateutil              2.8.2
pytz                         2021.3
PyYAML                       5.4.1
pyzmq                        22.3.0
qtconsole                    5.2.1
QtPy                         1.11.2
red-panda                    1.0.2
requests                     2.26.0
requests-oauthlib            1.3.0
rsa                          4.7.2
s3transfer                   0.5.0
scikit-learn                 1.0.1
scipy                        1.7.3
Send2Trash                   1.8.0
setuptools                   59.3.0
six                          1.16.0
tenacity                     8.0.1
tensorboard                  2.7.0
tensorboard-data-server      0.6.1
tensorboard-plugin-wit       1.8.0
tensorflow                   2.7.0
tensorflow-estimator         2.7.0
tensorflow-io-gcs-filesystem 0.22.0
termcolor                    1.1.0
terminado                    0.12.1
testpath                     0.5.0
threadpoolctl                3.0.0
tornado                      6.1
traitlets                    5.1.1
typing_extensions            4.0.0
urllib3                      1.26.7
wcwidth                      0.2.5
webencodings                 0.5.1
Werkzeug                     2.0.2
wheel                        0.37.0
widgetsnbextension           3.5.2
wrapt                        1.13.3
zipp                         3.6.0
0 Answers
Related