0

I am pretty new to python. Just been working through some online tutorials on udemy. I seem to have an issue with pip installing modules.

  • I've tried reinstalling them.
  • Upgrading my python version.
  • In VS I always just get module not found.

If I do it in the cmd prompt this is what I get below.

error

flaxel
  • 4,173
  • 4
  • 17
  • 30
Kevin Lay
  • 17
  • 6
  • 2
    seems like you should drop windows :) – anon01 Dec 27 '20 at 20:43
  • if you haven't, follow the tinyurl link at the bottom and google the specific error about windows runtime – anon01 Dec 27 '20 at 20:45
  • I have done this. But it seems they are having issues during program execution with certain functions. However most of what they are talking about is way over my head. – Kevin Lay Dec 27 '20 at 20:58

2 Answers2

0

It seems that you already have the packages installed. Using VS, please, be sure that you selected the correct Python interpreter (https://code.visualstudio.com/docs/python/environments)

nunohpinheiro
  • 2,169
  • 13
  • 14
  • It seems my VS is using the correct interpreter already. I run into the same errors in the VS terminal as I do in the cmd prompt. It should be able to import the module running python through my command prompt correct? – Kevin Lay Dec 27 '20 at 20:55
  • Use vs code and use bash. Or if you want to build MS skills us powershell cli in vs code. – BlackFox Dec 27 '20 at 20:58
  • Ok, it seems to be your numpy version. Maybe this is the solution :) https://stackoverflow.com/a/64658254/5220455 – nunohpinheiro Dec 27 '20 at 20:59
  • okay so this is interesting. I rolled the version back as they suggested. Now in my command prompt I can import numpy without error. However I still get the error in VS. I did a version check in VS and I do have the correct rolled back version. I am unable to use pandas or numpy in VS – Kevin Lay Dec 27 '20 at 21:07
  • great! But yes, that is interesting... Anyway, I would recommend you followed aargun suggestion on using a virtual environment – nunohpinheiro Dec 27 '20 at 21:14
0

You are currently working on the base environment of your computer. For safety, you can first create a new virtual environment with

python3 -m venv -n new_env

So that you won't corrupt any default installations. Then, activate it with

source new_env/bin/activate

And update the pip and setuptools with

pip3 install --upgrade pip
pip3 install --upgrade setuptools

Finally, install numpy via

pip3 install numpy

However, I would recommend using Anaconda to build your virtual environment. When you install Anaconda and make sure it is included in the path of your terminal, all you need to type is

conda create -n new_env python=3.7 numpy

and it will automatically build the wheel for numpy. Here, "new_env" is just an example for a virtual environment name, and Python version 3.7 is also an example.

You can then, activate this conda environment by

conda activate new_env

To use this virtual environment, which you built either with "venv" or "conda", you should locate and activate this environment from the project interpreter settings in VS .

Finally, I would also recommend considering Pycharm IDE which can also help you with creating a virtual environment and installing packages in it.

aargun
  • 126
  • 4
  • I am struggling with this a little bit. I have installed anaconda and setup a new environment through their interface. I then ran it from their interface and was able to import the module. However I am struggling with getting VS pointed correctly. I selected a new interpreter went to:C:\Users\kevil\.conda\envs\new_env – Kevin Lay Dec 27 '20 at 21:48
  • C:\Users\kevil\OneDrive\Documents\GitHub> cmd /C "c:\Users\kevil\.conda\envs\new_env\pythonw.exe c:\Users\kevil\.vscode\extensions\ms-python.python-2020.12.424452561\pythonFiles\lib\python\debugpy\launcher 54584 -- c:\Users\kevil\OneDrive\Documents\GitHub\PythonScripts\test.py " – Kevin Lay Dec 27 '20 at 21:49
  • sorry a simple reboot of VS after changing the interpreter seemed to fix it. It all appears to be working for now thanks to the anaconda – Kevin Lay Dec 27 '20 at 21:54
  • I’m glad it worked. If everything is fine now, I would appreciate it if you could accept the answer and close the topic – aargun Dec 27 '20 at 22:08