1

First off, I'm not a hardcore python coder so please bear with me.

So I'm trying to fix the existing script that my colleague had previously worked on. It was working fine until one day, it stops and now I'm stuck working on it.

I'm having this error below.

Collecting pandas
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x2b490dd86f28>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pandas/

Not really sure what's going on but when I checked, pandas is installed.

[root@berlin212 script]$ python3.6
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> print(pd.__version__)
0.23.0
>>>

First part of the script is this...

#!/bin/python3
# Use Python3.6
import pip
pip.main(['install','pandas'])
import pandas as pd

from datetime import datetime
import time
import openpyxl, re, os, sys
import numpy as np
import openpyxl

current_month = datetime.now().strftime('%B')
current_year = datetime.now().strftime('%Y')
current_month_year = current_month + current_year

When I did try to remove this part

import pip
pip.main(['install','pandas'])

It's now giving me this error.

[root@berlin212 script]$ ./formatting.py
Traceback (most recent call last):
  File "./GetVirtualMachines.py", line 5, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'
martineau
  • 119,623
  • 25
  • 170
  • 301
gafm
  • 351
  • 1
  • 9

1 Answers1

0

It seems like you are using anaconda environment.

Try:

conda activate your-anancoda-env

and open your .py file on the anaconda environment.