While Anaconda is nice, my experience trying to use Visual Studio through Anaconda is a mess. I have just ended up using Spyder which is great but I'd preferably use visual studio.
Couple of issues:
I select base conda interpreter in visual studio and proceed to try to import pandas or numpy. This results in an error (AttributeError: module 'tokenize' has no attribute 'Name').
A couple of days ago it randomly worked and now it's not. running print('hello') works just fine.
I have no issues with any imports in Spyder but I've started using Flask and it'd be much easier to have it all in one workspace.
Any understanding why I cannot import pandas.
Edit: Did a clean reinstall of both and now am able to install numpy. However, I get the error when trying to install pandas. Using 3.8.3. Pandas works in Spyder, not in VS Code.
Ok so it started working for no apparent reason. I just restarted VS Code through Anaconda and this time it had no issues. As I said, I feel like VS Code is all over the place through Anaconda and not very reliable.
Related
I'm now trying to run qiskit visualization functions(e.g. .draw() methods) in vscode.
I use latest version of Python, 3.11.1, and followed Getting Started Qiskit in here.
Also I installed qiskit extension in vscode.
However, when I run a qiskit code, the visualization functions don't work, even though code is compiled successfully.
I checked visualizing modules(mathplotlib, etc.) were installed.
I tried to re-install Python and vscode, including downgrading Python to 3.8. And it didn't work.
Additionally, qiskit-chemistry and qiskit-aqua installation warnings are pop-upped, but installation doesn't work.
I really don't know it is related on this problem, but I think maybe it's not since qiskit-aqua is deprecated.
The following screenshot is result of the qiskit test code.
result of running
draw() and plot_histogram() doesn't work as you can see.
How can I fix this problem?
These functions are meant to be used in Python Notebooks - they won't show up in normal .py files. Try using VSCode's Jupyter Notebook (.ipynb files) feature instead.
I got the P4 python module for win10 via the installer on their page: https://www.perforce.com/downloads/helix-core-api-python
Its for python 3.9, though I have tested it with both Python 3.10 and 3.9 and it always throws the error: No module named 'P4' when I try to use it inside visual code.
Interpreter is set up correctly (tried 310 and 39).
Im a bit lost here and would love some help.
The installer package installed the following files into site-packages:
P4.py
P4API.cp39-win_amd64.pyd
and a folder with 4 metadata files in it
P4.py on itself looks good, no errors.
Edit: Im trying to use it with Blender. Currently shipped python version within that is 3.10.2. Also tried a older blender version which uses 3.9.7.
Both wont work.
Visual studio code is known for it's bugs with python. You could try using "PyCharm". Make sure to install the modules from Pycharm's settings instead of terminal.
(I'm not sure if this is the reason, but it's worth the try. Had the same issue and the mentioned way solved it.)
So, I've been using VSCode for Jupyter notebooks for almost a year and a half now, and it always used to work normally, but a couple of days ago it just got broken, and I don't know why. Here's what I mean:
Jupyter Notebook on VSCode
As you can see, there's no syntax highlighting, and autocompletion doesn't work at all... but if I run the code, it does run perfectly.
It works normally in Python scripts though:
Normal Python Script
Relevant Extensions I've got:
Jupyter (+ Keymap & Notebook Renderers)
Python
Pylance
I've got a bunch of others for C++ and Java.
Also, I've noticed that both Jupyter and Python extensions give an uncaught error, here's what I mean:
Jupyter Extension Error
Python Extension Error
I have no clue what any of this means. I've tried uninstalling and re-installing the extensions, re-installing VSCode, resetting settings.json and restarting my laptop, nothing worked.
Any help will be highly appreciated. Thanks
Do you have installed the extension of Dependency Analytics? You need to disable it.
Some people have run across the same problem, you can refer to here.
I'm fairly new to IDE's and I'm trying to take courses in Python. No matter what I try, I cannot successfully run a python script that has import pandas and import numpy in it in either Visual Studio Code or Eclipse (running on Windows 10). I have Python 3.8 installed, and when I try running those commands in the shell it works fine. I suspect when I try executing an actual Python script instead of using the console, it might be using a different interpreter, and I only get errors when I try doing this, saying numpy is not defined. I also get the error "cannot import name 'numpy' from partially initialized module 'pandas' (most likely due to a circular import)" when I specify "from pandas import numpy" rather than "from pandas import *".
I am very frustrated and don't know how to fix this problem. I've tried searching for help but not having a programming background, I don't know where to go to resolve this or how.
I also cannot get pip or pip3 to work at all to install packages. Those commands don't get recognized.
Please help!
I recommend using Jupyter Notebooks/pycharm(IDE). Both are very useful for learning python and working with data, data manipulation, and data visualizations.
PyCharm knows everything about your code. Rely on it for intelligent code completion, on-the-fly error checking and quick-fixes & easy project navigation.
While
Jupyter Notebooks can run line by line, rerun specific lines after making changes, and it's inline output is very useful for debugging and visualizations. You can get it from https://jupyter.org.
Zepellin Notebooks can also serve as alternatives.
Recently, I started learning python. I'm at the 8th chapter of a book called "Automate the Boring stuff with Python". The author uses a module named 'pyinputplus'. I installed this module with pip (pip3) and tried to play with it in my terminal, and it worked.
After playing around with this module, I decided to make a small project in Visual Studio Code. I had the "Python" plug-in installed. (It was made by Microsoft, and it had linting, debugging, syntax highlighting and more.) Strangely, it started throwing errors. This was my code:
import pyinputplus as pyip
It seems to work fine without the plug-in, although running it without the plug-in wasn't very convenient, as I had to run it in my terminal every time.
This was what is was saying:
Cannot import 'pyinputplus' due to syntax error 'invalid syntax (, line 268)'
Obviously, I didn't have this many lines in my code. (I had only one line of code.) I'm guessing this is a bug, but as a beginner I'm not really sure. Does anyone else have this problem? Any answer would be appreciated.
Here are my plug-ins in use, Vscode version, etc.
MacOS Version: 10.14.6
VsCode version: 1.47.2
Python-related plug-ins/extensions: 'Code Runner' and 'Python'
Python version: 3.8.4
I tried reloading VSCode, But it still didn't work.
First, you have to install that module on your computer.
By using:
pip install pyinputplus
Then, you can import it by:
import pyinputplus as pyip
and then, you will get results like this.