Pandas import module missing in VSCode - python

I am having issues with importing the pandas library into my project on VS Code. I have pandas installed on my machine and my machine is currently running python 3.9.12. I tried changing the interpreter in my IDE from 3.10.64 to 3.9.12 but I cannot find the path to it. I was wondering if there was anything else I should try/do to help fix this issue. Thank you!

Make sure you set the path using your environment variables as shown here
Then, using pip, just simply do !pip install pandas in order to have the pandas path set correctly automatically. I understand you may have installed it manually but this may help.

Related

Pandas is not working, even after I installed it

I currently need to use pandas with Thonny, because pandas is installed locally there, but all my coding is in visual studio and i want to be able to use pandas in the editor i like. I have this error while trying to run a code for pandas.
No module named 'pandas'
File "/Users/myname/Desktop/Ambassador.py", line 1, in <module>
import pandas as pd
Even tho i have already installed it, i've made several attempts with pip, conda, i installed wheel and everything suggested.
Anyone knows why is this ?
for additional info i have a Mac
Check python version where pandas is installed and use same version to run your code
It could be cause you have installed pandas at the different virtual environment. I guess, you should try to check and change environment (⇧⌘P) in visual studio especially if you are using things like conda.
Also, check it for info about environments: https://code.visualstudio.com/docs/python/environments

I am receiving and import error when trying to import cv2 in python (Ubuntu 18.04)

First of all, thank you very much for reading.
Some days ago I installed Python3 (3.6.9) and opencv 3.4.10 in an Ubuntu 18.04 desktop system. I needed to downgrade opencv to 3.4.0 after some compilation problems (not related to python3), so I removed opencv 3.4.10 by using the sudo make uninstall order, and tested that it was uninstalled as if I tried importing it in python I got the following error:
libopencv_hfs.so.3.4: cannot open shared object file: no such file or directory
I thought installing 3.4.0 version would solve the problem but now that it's installed, when I try to import it in a python3 script I am getting the same error. I think this error must be related to the way python3 references the import files. I think it's still pointing to the uninstalled version of 3.4.10, but I can not find the way to change it.
Could someone please help me with this issue?
Thank you very much.
Andrés.
Using a virtualenv would resolve the issue. Check this out on how to use : Installing packages using pip and virtual environments
Once you're done installing requirements in the virtualenv, run your python script there only to use the specified versions.
Hello again and thank you for you answers.
I have been able to solve the problem. Thought I had uninstalled the previous version of opencv, there was still a cv2.sofile in my python virtual environment path, and it had not been replaced by the new cv2.so, so python tried to import the old one instead of the new one.
The old cv2.so (the one that was referenced when I imported cv2 in python) was here --> ~/.virtualenvs/cv/lib/python3.6/site-packages/cv2.so
The cv2.so I wanted to be used when imported was here --> /usr/local/lib/python3.6/site-packages/cv2/cv2.so so I replaced the one in the virtual environment path with the one in the lib directory and that did the trick :)

Problems to use pandas within Visual Studio Code

I have installed pandas then tried to import pandas
Code:
import pandas as pd
print("Test Pandas")
Error Type:
Exception has occurred: ModuleNotFoundError
No module named 'pandas'
I already have Python, Pip and Pandas installed, but when I am trying to use the pandas within Visual Studio Code the error bellow appears.
Someone could help me, please?
Try entering the terminal in VS code (CTRL + ~) and enter a python environment (type python and then hit enter). From there try the command:
help("modules")
That will show you packages installed in your current project environment. If you don't see pandas, it's due to difference in environment and just need to pip install pandas again from inside the project env.
Side note: one thing that can help to avoid this kind of problem for you in the future is using virtual environments

How to use tensorflow in pycharm?

I have installed tensorflow on my Ubuntu, I can import it from shell but I can't from pycharm. Here is my screen :
How can I solve this?
You should name your project differently: now you are trying to import package tensorflow (your project) and use it inside of it.
Try to rename your working directory to tensorflow_test or something different than tensorflow.
You have to change the python interpreter that PyCharm is using.
Go to options->project->project interpreter and select the correct one, most likely a virtualenv you created, where you installed tensorflow instead of the default.

Pandas Import error after installation in Wing IDE

I am having some major problems importing Pandas and it is driving me crazy.
I installed Pandas from terminal using
pip install pandas
as well as all dependencies.
Now when I try to import pandas I get
ImportError: No module named pandas
This is true in terminal and in Wing.
I have tried changing python path but I am not really sure how to do that. I am a Stats guy not really a developer. My goal ideally is to have Wing point to the python where pandas is located but also to be able to access pandas in terminal as well:
Mac / usr / local / lib / python2.7 / site-packages / Pandas
When asking in terminal
which python >>> /usr/bin/python
Which is running python 2.7.6 and the pandas package is sitting in my python2.7 folder, so I don't know why it's not recognizing it.
Is this a quick fix or a deeper issue in the way I installed pandas, Wing, and python?
You have two different Pythons in your system: Apple's default one in:
/usr/bin/python
and one in:
/usr/local/bin/
If you run:
/usr/local/bin/python34
you will be able to import the packages installed with pip34:
pip34 install pandas
If you want to permanently use the new Python, then make an alias or change the search order in our PATH env variable so that /usr/local/bin/ is searched before /usr/bin.

Categories