I switched to Visual Studio Code for Python programming recently. Below is my Python configuration in Visual Studio Code settings:
"python.pythonPath": "/Users/hzhang/.virtualenvs/env-2.7/bin/python",
"python.autoComplete.extraPaths": [
"/Users/hzhang/Work/xxx/shared_modules"
],
Basically, I just configure the Python interpreter and add one extra shared module path.
When I try to refactor a variable name, it throws this error which says rope is not installed, and it doesn't work even I install it. Based on my understanding, refactor variables is a feature of Visual Studio Code, and it shouldn't rely on any specific language.
How can I fix this problem?
Once I installed rope, refactor was still not working. It popups this error:
I am on Python 2.7
Visual Studio Code: Version 1.19.3 (1.19.3)
Rope version: 0.10.7
Renaming of variables is not a native Visual Studio Code feature for languages other than JavaScript and TypeScript.
It is specific to each language, and functionality is provided by separate extensions, specific to each language. The Python extension you have installed, uses the Rope library to perform refactoring/renaming of python variables and the like. So yes, you'll need to install it by closing in the Install rope button.
If you don't have the Install rope button, you can just go to cmd and type pip install rope. That should do the job as well.
If it doesn't work even after installing it, please could you file an issue on the Python extension GitHub repository.
Update from the filed bug: Anaconda users need to install the Anaconda package instead of the regular pip default install that Visual Studio Code provides.
This worked for me:
conda search rope # The latest right now is 0.11.0
conda install --name mypy27env rope
On Ubuntu, miniconda:
I had this issue using the "VSCode Python Plugin", when selecting "conda" install for rope.
I changed the active env with Terminal using "conda activate env". Then with "conda list", I saw Build Row was at value py_0 and at version 0.16.
I've chosen conda remove rope
Then, installing with pip (rope version 0.17.0): pip install rope
"conda list" gave me now pypi_0 as value in Build row
Restart VSCode
Summarize, one of this helped:
- Reinstalling rope with pip in the active conda environment
- Restarting VSCode
Related
Recently I started using Spyder for my python programming. One of the Code required QT version greater than 5.12 so I installed standalone version of Spyder. To install additional packages I am using Anaconda. Despite of creating virtual environment I am not able to use Spyder as kernel throws error. " The Python environment or installation whose interpreter is located at
/Users/ugowda/opt/anaconda3/bin/python
doesn't have the spyder‑kernels module or the right version of it installed (>= 2.2.1 and < 2.3.0). Without this module is not possible for Spyder to create a console for you.
You can install it by activating your environment (if necessary) and then running in a system terminal:
conda install spyder‑kernels=2.2
or
pip install spyder‑kernels==2.2.*"
Tried several online suggestions,didn't work. Did anyone face similar problem ? Do anyone has solution ?
I used this command after I activated my env:
pip install spyder-kernels==2.2.1
Visual Studio says I'm running Python 0.0 AND 3.10
Visual Studio is unable to find a package. I am able to run it in cmd using python.
I have had this problem before, but can't remember how I fixed it. I think I'm using the wrong version of python, but if that is the problem I don't know how to fix it.
Edit: using py -3.10 -m pip install package, instead of just pip install package seems to have worked.
Check the version in cmd and then if it is something above 3.7 or so you are good to go else reinstall python and if you are on Windows then check the box at bottom of the installation window of python which says "Add pip to path" something like that
Now in the VS Code
Hit Ctrl+Shift+p to open command palette and in that search for python interpreter and change it to plain one or you may choose
Select Python Interpreter
use the vscode console
First of all to check the packages insatalled in python you have to use the pip freeze.
pip freeze
This will help you to find out if the required package which you've installed is on the list or not.
If it is not present use the same console for:-
pip install <packageName>
for eg.
pip install django
then check the list agian
I want to upgrade my base environment to Python 3.8. According to the official documentation, I should just run conda install -c anaconda python. This, however, only upgrades Python 3.7, so, in the end:
(base) C:\Users\bob>conda install -c anaconda python
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(base) C:\Users\bob>python --version
Python 3.7.6
conda update -c anaconda python only updated a number of packages, but not Python itself.
And if I specify a version, like explained here, after two hours analyzing dependencies, the upgrade fails because of conflicts.
I managed to set up a 3.8 environment, but I'd rather upgrade my base environment as it's the one my system path for use outside of Anaconda.
Any suggestion?
It doesn't appear to be possible to update the base version of anaconda to 3.8 yet because of the conflicts you mention. I assume once all the standard packages are updated to support 3.8+ (and updated versions of all dependencies), then the anaconda release will include 3.8.x as the default. This might take a while.
The problem here is version conflicts in the packages that anaconda installs by default. The reason you can install 3.8 in a clean environment is because no other packages are installed in that environment, so no conflicts.
This does now present a solution, although it requires reinstalling everything from scratch...
disclaimer: I don't use windows, so adapt my instructions accordingly to your OS.
Remove your existing anaconda install from the path and delete
anything in your bashrc (or windows equivalent) that points to it.
You can just delete/uninstall anaconda, but it's good to have a backup just incase, so leaving it there and removing links to it is a good option.
Download and install miniconda, and put it in your path as you had before.
Install python 3.8 in the base environment conda install python=3.8
Install all the packages that you need to do whatever you do.
Depending on what you install, at some point you may run into the same conflicts that prevent a standard anaconda install from updating at the moment, but that hasn't happened for me.
The latest stable version of anaconda is version 3.7
Please see here:
https://www.anaconda.com/distribution/
There isn't an option to get python 3.8, this is due to anaconda sometimes running a version behind the release of python.
I had the same issue and found there is a 2020-07 release of Anaconda with Python 3.8 https://www.anaconda.com/products/individual
Installing Python packages can be as frustrating as it can be. Maybe I am the only poor pathetic who still stucks in Windows and the world is living their world happily in Mac and Linux
I am trying to install vaex in my venv environment in Windows. But I got the following unmovable enterprise obstacles:
pip install is not possible as I am unable to install the Visual C++ Build Tools which requires admin rights
Direct Git download or clone do require Visual C++ Build Tool
Conda only up-to version 4.3 which I am not allow to set the proxy when I try to use the conda-forge channel to install
Conda 4.3 is not accepting proxy server settings via command line. There is no way I am able to make conda to use .condarc file. The solution I was proposed is to upgrade to 4.4 which I am not able to do that
Other dependencies pop-up when I try to upgrade conda to 4.4. conda upgrade conda forces me into a whole list of packages that I need to upgrade/install along where I was given no choice to select only conda
Or alternatively, what can I do to compile all the required elsewhere and repackage the whole package for installation?
You could build the wheel distribution of this project (and all its dependencies) on another Windows machine of the same bitness (32 or 64 bits) and with same (minor) version of the Python interpreter. This wheel distribution can then be reused on the target machine.
I have problems getting a project started. I want to work with the library OpenCV in Python, using Visual Studio 2017 as IDE (on windows 10). I added Python extensions (e.g. Anaconda3 64 Bit) to VS via the VS Installer. After that, the struggle begins. Someone told me, Anaconda would be nice to handle multiple packages, so I opened the Python IDE window and set Anaconda as default. Then in the same window I clicked on packages. After executing
conda install -c conda-forge opencv
conda install -c conda-forge/label/gcc7 opencv
conda install -c conda-forge/label/broken opencv
with the text field above the listed packages I was able to see the opencv package in that list. But when I tried to import opencv in a new python file, it didn't work. (The package was not found)
I also tried to download the latest OpenCV version on the official site, but there I got a folder. I navigated throught this folder and found some .pyd (python extension) files. Can I include them in VS?
I hope anyone can help, thanks in advance!
You can use/try/check the Python Environment Tab (View, Other Windows, Python Environment) to install stuff to any "environment" you have installed:
No idea if it is more comfy or not - I generally use that to install missing dependencies (using pypi - not conda) and the search input to check if it went ok:
I mostly use the python 3.6 for dev - so not much installed over anaconda defaults.
HTH