Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

pip - The problem is importing the pytz package into Python

Can you please tell me how I can use the pytz package in Python2 version? I am trying to run one script that works under Python2 version:

┌──(root??kali)-[~/passer]
└─# python passer.py                                                                              1 ?
Traceback (most recent call last):
  File "passer.py", line 33, in <module>
    import pytz
ImportError: No module named pytz

I have verified that I have the package installed:

┌──(root??kali)-[~]
└─# pip list | grep pytz
pytz                         2020.5                                                                                                      
┌──(root??kali)-[~]
└─# pip3 list | grep pytz
pytz                         2020.5

Can you please tell me what could be the problem? Thank you so much.

OS Kali linux 2020.2

question from:https://stackoverflow.com/questions/65896967/the-problem-is-importing-the-pytz-package-into-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So, I managed to solve this problem as follows, by requesting versions of pip and pip3 packages, I noticed that all links go to /usr/lib/python3/dist-packages/ I looked at the dist-packages folder and saw that there are many packages, and the folder of the same name, but only in the python version 2 folder, is empty, i.e. here: python2.7/dist-packages/ I took and copied the packages I needed from the Python3 folder to the Python2 folder, this is of course complete absurdity, but it worked for me. I understand that this is a temporary and not a good solution to the problem, but how can I install the necessary packages in python2 in the future? because now everything is referring to python3


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...