Skip to content

DOC: Added documentation for ImportError's #30912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/getting_started/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Customarily, we import as follows:
import numpy as np
import pandas as pd

Note: In case you encounter an import error, :ref:`Handling ImportErrors` section of installation documentation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the CI error: https://github.com/pandas-dev/pandas/pull/30912/checks?check_run_id=388068051#step:6:4623

I don't think you can add a link using the title section. You'll have to create a label before the title section, and link with the label. You should plenty of examples in the docs, but the label should be something like:

.. _install.import_errors:

and this link something like:

:ref:`Handling ImportErrors<install.import_errors>`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the help!! I felt that it was an unnecessary line either way so on removal, the checks passed.


Object creation
---------------

Expand Down
29 changes: 29 additions & 0 deletions doc/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,35 @@ To install pandas for Python 2, you may need to use the ``python-pandas`` packag
to get the newest version of pandas, it's recommended to install using the ``pip`` or ``conda``
methods described above.

Handling ImportErrors
----------------------

If you encounter an ImportError,it usually means that Python couldn't find pandas in the list of available
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you encounter an ImportError,it usually means that Python couldn't find pandas in the list of available
If you encounter an ImportError, it usually means that Python couldn't find pandas in the list of available

libraries. Python internally has a list of directories it searched through, to find packages. You can
obtain these directories with:
import sys
sys.path

One way you could be encountering this error is if you have multiple Python installations on your system
and you don't have pandas installed in the Python installation you're currently using.
In Linux/Mac you can run "which python" on your terminal and it will tell you which is the Python you're
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use double backticks for which python.

using. If it's something like "/usr/bin/python", you're using the Python from the system.(Not recommended)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using. If it's something like "/usr/bin/python", you're using the Python from the system.(Not recommended)
using. If it's something like "/usr/bin/python", you're using the Python from the system, which is not recommended.


If you used Python before you may have used virtual environments and pip. While this is fine for many
Python projects (e.g. Django), when using data projects (pandas, numpy, tensorflow, etc.) this is discouraged.
It's easily susceptible to installation errors and the libraries can run slower while using pip to perform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It's easily susceptible to installation errors and the libraries can run slower while using pip to perform
It's easily susceptible to installation errors in non-Python dependencies and the libraries can run slower while using pip to perform

small detail, but I think it's better to clarify, since we don't want to give the impression that pip is unreliable.

installations.
The widely used solution to this problem is to use conda. You can find simple installation instructions
for pandas in this document: https://dev.pandas.io/getting_started.html.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for pandas in this document: https://dev.pandas.io/getting_started.html.
for pandas in this document: /getting_started.html.

The dev.pandas.io domain is probably going to disappear, and the production page anyway will be in pandas.io. But it's better to not use the domain, in case we change it in the future.

Also, it's probably better to use something like (or at least make the link clickable.

You can use the simple `installation instructions </getting_started.html>`_ in the pandas website.


Another possible way of fixing the error is by first finding the version of your python installation with:
python --version

If you get Python 2.7.x, then try the following command to install pandas:
sudo pip2 install pandas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this last part please, we surely don't want anyone to install pandas in the root environment as root. :)


If you get Python 3.7.x, then try the following command to install pandas:
sudo pip3 install pandas

Installing from source
~~~~~~~~~~~~~~~~~~~~~~
Expand Down