0

Issue on importing Python Library

Background

  • I am on MacOS 10.14.5.
  • I currently cannot import any Python third-party Library from anywhere (including VSCode, Pycharm and terminal).

Detail

  • For example, I have been using pip3 install pandas to download the Python Library:

pip3 list

Package           Version 
----------------- --------
astroid           2.2.5   
beautifulsoup4    4.7.1   
certifi           2019.3.9
chardet           3.0.4   
idna              2.8     
isort             4.3.16  
lazy-object-proxy 1.3.1   
mccabe            0.6.1   
numpy             1.16.4  
panda             0.3.1   
pandas            0.25.0  
  • However, I just cannot import it:

python3

Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas
  • (Same problem exists in any other editor)

  • Also, when I am trying to install Libraries by Pycharm, it reports:

    Collecting pandas

    Could not install packages due to an EnvironmentError: Missing dependencies for SOCKS support.

  • However, even after turning off the proxy, the problem still exists.


If there is any other operations needed for diagnosis, please tell me! Thanks for helping!

yChen
  • 11

1 Answers1

1

You should check where pip is installing Pandas and from where Python is retrieving its library.

Try:

pip show pandas

On Python try:

import sys
for path in sys.path:
    print(path)

Then check if everything is OK. You probably have more than one Python installation.

174140
  • 94
  • 2
  • 14
  • 33
nicmano
  • 11
  • Hi, here is the return:

    pip show pandas Name: pandas Version: 0.25.0 Summary: Powerful data structures for data analysis, time series, and statistics Home-page: http://pandas.pydata.org Author: None Author-email: None License: BSD Location: /usr/local/lib/python3.7/site-packages Requires: pytz, numpy, python-dateutil Required-by:

    – yChen Sep 01 '19 at 07:42
  • The another return is: – yChen Sep 01 '19 at 07:42
  • python3 Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information.

    import sys for path in sys.path:

    ... print(path) File "", line 2 print(path) ^ IndentationError: expected an indented block

    – yChen Sep 01 '19 at 07:42
  • It is just confusing. The syntax should be right, but it just reported an indentation error – yChen Sep 01 '19 at 07:43
  • I am not sure what do you mean by "more than one python installing". I have both python3 and python2 installed. However, I think I have carefully used "python3" and "pip3".. – yChen Sep 01 '19 at 07:46