0

I have successfully installed Python 3.10. I want to install packages. Pandas, BeautifulSoup4, and requests.

I tried to import NumPy but IDE says it doesn't have the NumPy module.

I searched for it in directories and it turned out NumPy is in the 3.8 version.

I used the command on the terminal:

sudo python3 -m pip install Pandas

Which installed it successfully.

But the package files are installed in Python 3.8.

Now I have the following Directories:

  • /Library/Python 3.8
  • /Library/Frameworks/Python.framework/Versions 3.10
  • /Applications/Python 3.10
  • /usr/local/bin 3.10

In /Library/Python there is only 2.7 and 3.8 versions

Python 3.8

In following directories version is 3.10:

  • /Library/Frameworks/Python.framework/Versions 3.10
  • /Applications/Python 3.10
  • /usr/local/bin 3.10

/usr/local/bin

/usr/local/bin

/Library/Frameworks/Python.framework/Versions

/Library/Frameworks/Python.framework/Versions

/Applications/Python

/Applications/Python

What will happen if i remove 3.8 or can i update it to 3.10?

Danish Arain
  • 110
  • 1
  • 9
  • 1
    When you try `python3` by itself, what version of Python gets run (according to the welcome message in the interpreter)? Anyway, as a rule *do not ever remove any version of Python that came pre-installed on your computer*. There is no telling what might be dependent on it. Anyway, it's not clear what your **question** is. Did you actually mean "how can I ensure that a package is installed in 3.10"? "How can I start the 3.10 interpreter explicitly"? "How can I ensure that a script is executed using 3.10"? Something else? – Karl Knechtel May 14 '22 at 16:52
  • @KarlKnechtel when i run python on ide or terminal it says 3.10. – Danish Arain May 14 '22 at 16:59
  • @KarlKnechtel If it is not recommended to uninstall pre loaded python then how can i ensure that my packages are install in 3.10 instead of 3.8. – Danish Arain May 14 '22 at 17:01
  • 1
    If that's the question, then you should *explicitly ask it*, in the post itself. – Karl Knechtel May 14 '22 at 17:02

2 Answers2

1

Is better to use a virtual environment and install in it python 3.10, removing Python 3.8 can may some problems, so avoid removing it, and if you are open to using different tools, I advise you to use Jupyter Notebook.

1

Don't follow this (go to EDIT instead):

I found my answer here: https://stackoverflow.com/a/25123329/13377578

Just had to specify the version of Python I want to install the package in.

sudo python3.10 -m pip install Pandas

Now it works. Thanks.

EDIT:

Thanks for the comments below. I am new to Python and didn't know what environments were.

I followed this simple guide.

I made an environment for my project (my system-level python is now safe from messing up) and now everything works.

Create Environment:

cd python-projects

Python3.10 - m venv Venv_Name

source pit-ds/bin/activate

Installing Packages:

pip list

pip install Pandas

pip install BeautifulSoup4

pip install Requests

Run IDLE within Virtual Environment:

python -m idlelib.idle

Deactivating Environment:

deactivate
Danish Arain
  • 110
  • 1
  • 9
  • you probably don't want sudo... – juanpa.arrivillaga May 14 '22 at 19:24
  • 2
    No, that's wrong! Don't install anything into your system python3.10. You *have to* use venv, its super easy! `python3.10 -m venv venv` then `source venv/bin/activate` then `pip install pandas`. – psarka May 14 '22 at 20:13
  • I have edited my answer. Thanks for teaching me something new. @psarka – Danish Arain May 14 '22 at 22:02
  • 1
    Never, ever use `sudo` with pip. The [makers of PIP themselves warn about this in no uncertain language](https://github.com/pypa/pip/issues/5599) – Brian61354270 May 14 '22 at 22:08
  • Before posting the question I was researching this and someone in a different question's answer suggested sudo. Thanks, I didn't know that. @Brian – Danish Arain May 14 '22 at 22:18
  • 1
    @DanishArain Awesome, I'm glad you paid attention to advice! I take back my -1 and replace it by +1. – psarka May 14 '22 at 23:02