My First Day Learning Software: Installing Python, Jupyter Notebook and MXNet

Currently, I’m practicing with the textbook “Dive into Deep Learning (d2l-en.pdf)”. At this stage, I haven’t systematically outlined my study notes, so I can only record the situations I encounter. Among these, ChatGPT’s responses have been very detailed, helping me resolve major issues, which prevented me from giving up before even starting to install the software.

  1. During the installation process, I successfully downloaded Miniconda and smoothly completed the initial steps. However, when installing mxnet, I encountered several issues. Initially, attempting to install CUDA, I tried the exe (network) version and was unsure about the required workloads. I saw options like desktop development with C++, .NET Multi-platform App UI development, Net desktop build tools, Windows application development build tools, as well as Azure and SQL-related tools. Due to its large size, after confirming with ChatGPT, I downloaded only “Desktop development with C++”, but installation still failed.
  2. Subsequently, I attempted to install the CPU version of MXNet. However, I continued to encounter errors during this process, without understanding why. Also, when installing packages, the system would display extensive code scrolling before throwing an error. Uncertain about what was happening, I asked ChatGPT questions like “What’s the problem?” or “Did d2l install successfully?” and pasted all error feedback codes. This was very useful. I realized that many software/libraries and Python versions were incompatible, so I followed prompts to reinstall repeatedly. Eventually, I successfully unpacked the files and opened Jupyter Notebook. I had learned about Jupyter Notebook last month during my Data Science studies, and I was glad to remember it. After that, I went to sleep; it was past two in the morning. This whole process took nearly two hours.
  3. The next day, upon waking my screen, I found that my Anaconda Prompt editor was unresponsive. I had to restart, unsure if I needed to redo all the previous steps.

I copied the following from the textbook:

Copy codefrom mxnet import np, npx
npx.set_np()

When I entered this directly, the system returned an error.

AI told me:

  • The error occurred because you entered Python code directly in the command prompt. You need to enter the Python interpreter first or create a Python file and execute it.
  • Enter the Python interpreter: Open the command prompt and type python, then press Enter to enter the Python interpreter.
python

Under the Python interpreter prompt >>>, enter your code:

from mxnet import np, npx
npx.set_np()

I copied the code as instructed but still got an error:

(base) C:\Users\shere>python
Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mxnet import np, npx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mxnet'
>>> python test_mxnet.py
  File "<stdin>", line 1
    python test_mxnet.py
           ^^^^^^^^^^
SyntaxError: invalid syntax
>>>

I received the response: “Your problem is because mxnet is not installed or Python interpreter is not running in the correct virtual environment.

Activate your virtual environment:

conda activate new_env

Install mxnet:

pip install mxnet==1.8.0.post0

Check if installation was successful: Start the Python interpreter in the virtual environment and try to import the mxnet module:

python

Then enter the following code in the Python interpreter:

from mxnet import np, npx
npx.set_np()

Then I tried and received another error feedback:

>>> conda activate new_env
  File "<stdin>", line 1
    conda activate new_env
          ^^^^^^^^
SyntaxError: invalid syntax
>>> pip install mxnet==1.8.0.post0
  File "<stdin>", line 1
    pip install mxnet==1.8.0.post0
        ^^^^^^^
SyntaxError: invalid syntax
>>>

AI told me:

“First exit the Python interpreter:

exit

Make sure to run the following commands in the command prompt (terminal), not in the Python interpreter:

conda activate new_env

Install mxnet:

pip install mxnet==1.8.0.post0

Start Python interpreter:

python

Enter the code:

from mxnet import np, npx
npx.set_np()

Then, I still got an error:

>>> npx.set_np()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'npx' is not defined

AI suggested I check:

“The issue may be because mxnet is not correctly installed or Python is not running in the correct virtual environment. Please ensure you correctly activated the virtual environment as per the previous steps and installed mxnet correctly.

Useful code:

Check if mxnet is installed:

pip list

Check the PATH environment variable: Ensure that the directory containing libmxnet.dll is in the PATH environment variable. Enter the following command in the command prompt to view the current PATH environment variable:

echo %PATH%
Check if C:\Users\Admin\.conda\envs\new_env\lib\site-packages\mxnet\ is included in the output.

If it’s not included, you can add it with the following command:

set PATH=%PATH%;C:\Users\Admin\.conda\envs\new_env\lib\site-packages\mxnet\

After this, I found it incompatible, so I reinstalled MXNet:

pip install mxnet==1.7.0.post1

The system confirmed success, and I started Python, proceeding smoothly with the calculations thereafter.

Leave a comment

Trending