I am using PyCharm 3.4.1 (professional version). And I am exploring Scikit-Learn, NumPy etc. But unfortunately I can't get methods/properties/module in PyCharm when I write code with any installed package instead of Python core. Though when I import any module at the beginning of any .py file, it shows the corresponding methods/modules after pressing dot(.), but in code, PyCharm does not show the list after pressing dot(.).
How I can get all things after pressing dot(.)?
Thanks!
Related
I've been trying to use the packages pandas, numpy, matplotlib, seaborn in my "Visual Studio Code", but the program keeps showing me the following message:
"import pandas could not be resolved from source Pylance(reportMissingModuleSource)"
Previously to Visual Studio Code I installed "Anaconda" to use Jupyter, and now it says that i have the existing packages (pandas, numpy...) but keeps appearing this message that doesn't allow me to use pandas in my Visual Studio.
Anyone could help me to solve this issue?
I tried installing again all the packages to check if they didn't exist but apparently are installed all of them but in another route. I can't find how is the way to put them so the Visual Studio Code recognizes them and I can use them.
I also received similar an error on my IDE VSCode and currently using mac m1 .First we need to make sure that the python3 interpreter version from terminal version is the same with our python version selection in VSCode.
open terminal.
type 'python3'
then you will see your python version.(my python3 version is 3.9.12)
python3 version
open your IDE VSCode
open any/current folder that related to python project on IDE VSCode
Check your python version at the bottom right on IDE VSCode (in my case the python version is 3.10.64)
change or switch VSCode python version from 3.10.64 to 3.9.12 (same with your python version on your pc)
done
I also had this problem and it was because of version mismatches.
I had installed Python AND Anaconda. If anyone else has done this and gets this error, you need to uninstall both. Then install Anaconda only; Python (the compatible version) is installed as part of that process.
See https://docs.anaconda.com/anaconda/install/windows/
Also, you can click on the interpreter version at the bottom left corner of the screen (Vs.code 2022) it should show a dropdown menu with a list of the available and selected python interpreter. Click on add interpreter path and paste the path to the python interpreter with all the required modules installed and click enter. This should resolve the problem.
I re-entered the path to Python interpreter and warning disappeared. Hope that helps you.
Another way I solved this issue having followed every other installation process to the letter was deactivating Pylance. Works a (py)charm now.
I encountered this problem in VSCode under remote to WSL2 of Windows 10. The Python version is correct as interpreter (3.9.13) and the terminal in VSCode is also under the same envs (ie. VSCode ran "conda activate xx" and (xx) is shown in prompt)
Originally, I tried to install the pandas by the following command.
sudo apt-get install python3-pandas
Pandas was installed successfully as stated in the terminal but the problem is still there.
When I try to install pandas by the following command, the problem solved.
pip install pandas
I'm running a simple .py file that only contains
import pandas as pd
in the visual studio code terminal on my desktop and I get this error ModuleNotFoundError: No module named 'pandas', but when I run
import pandas as pd
in a cell in a .ipynb file in visual studio in the same directory it runs fine. What might be the problem here?
UPDATE: In fact, simply running
python3 test.py
in the terminal runs the code perfectly. So I seem to be not understanding something about how to use the visual studio code terminal
It sounds like VS Code automatically chose the "wrong" python environment (i.e., not the one where you already installed pandas), so you have to manually select the right environment:
Hit Ctrl+Shift+P and go to Python: Select Interpreter:
Choose the "right" python environment, the one where you already installed pandas:
Python virtual environments
In general I suggest using virtual environments for all your python stuff. I generally don't worry about which interpreter VS Code chooses because I always just activate the particular environment I need for any given project (e.g., source .venv/bin/activate, pipenv shell, poetry shell, etc.).
Until today, matplotlib was working with vscode. TOday I updated vscode to the latest version and found that plots don't work. They work from the same virtual environment using the python interpreter but not from vscode. I rolled back to earlier versions of both matplotlib and vscode, but it still doesn't work. Here is my code to plot:
import matplotlib
import matplotlib.pyplot as plt
plt.plot([1,2],[3,4])
plt.show()
The version of vscode is 1.53.2 and the version of matplotlib is 3.3.4
If I call plt.savefig, it saves the figure. It just doesn't display interactively.
I have tried this with multiple virtual envioronments and multiple vscode workspaces, all of which worked before today.
VSCode doesn't see my DISPLAY environment variable on my Linux system, so it is running headless. I can make plots work by giving the command "export DISPLAY=:0" in the vscode terminal window. I would like to have this happen automatically but I don't know how to make that happen.
The way I discovered this was by inserting "matplotlib.use("TKAgg")" in my python script. This elicited a message saying that I was running headless.
The way I found the correct value for DISPLAY was to examine that variable in a terminal window outside of vscode.
When I went to report this on the vscode Github page, I found the suggestion to disable all extensions. When I do that, I don't have to set DISPLAY. I then went and reenabled all extensions, and plotting still works, so it seems the fix was to disable and reenable all extensions.
I have installed NumPy using pip install and it's working fine while using it in the python interpreter on the command line. But whenever I try
import numpy in PyCharm it throws an error module not found.
I already set the right path in the project interpretor and the import numpy command is working fine with other IDEs such as Syder or Jupyter notebook but it doesn't work in PyCharm.
I found a YouTube video that worked for me in importing a package into PyCharm. First, click on the File menu, then click on Settings, then click on Project Interpreter. Look for a + sign to the right and click on that. That allows you to add a package. Then search for your package of choice (I wanted numpy) in the Search bar at the top. Click on the name, and then at the bottom click on Install Package. After a few minutes, it will say, package successfully installed, and sure enough it was. I was able to import numpy the usual way in PyCharm.
Did you install official Python or Anaconda/Miniconda?
I assume PyCharm created either a virtualenv or a conda env, or an isolated Python environment that does not have NumPy installed.
You should either use your global environment instead of virtualenv:
Settings, Project: project-name / Project Interpreter, https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html
Or install NumPy in your virtualenv or conda env.
This is more complicated. If you open Terminal in PyCharm and it says (project-name) in your prompt, try pip install numpy.
I install selenium through Python pip and write a simple file called crawlTest.py, it works well.Later, I install Pycharm and try to auto complete method from selenium, but it doesn't work.
I guess Pycharm didn't know where I install selenium and an external library is needed.But I try by myself and search on google and StackOverflow, I didn't get proper solution.
I have read the flowing posts, but still not work. It is very useful and
time-saving for those who use selenium and Pycharm if some one could give me .
here is post list I hava viewed:
How to get PyCharm to auto-complete code in methods?
PyCharm doesn't auto-completes very simple cases such as: import pickle
I install selenium by python pip, and it works with python3.5,but not python 2.7. so I changed my project interpreter as python 3.5 in Py . Now it works!
for use auto-complete Pycharm feture go to "File\Setting\Project:" add new interpreter and select you instaleed python directory.