I installed discord.py with the voice and without in the visual studio code terminal because in my cmd it doesn't detect pip like a command (I'm on windows). I've tried too in the python terminal but it doesnt detetect pip like a command.
Please help.
Pip is installed, it's just not installed as a command, and that's on purpose. What you want to do is create a virtual environment and then install into there by activating the environment and then using python -m pip.
Related
I'm trying to make a discord bot, and I keep getting this error:
Import "discord" could not be resolved Pylance(reportMissingImports)
I used this to install the package:
py -3 -m pip install -U discord.py
I am using the cmd on Visual Studio Code for this. Can anyone help?
Try these steps:
Run VS Code as administrator > Navigate to your project path in the Terminal (CMD) in VS Code > Then Run the command py -3 -m pip install -U discord.py
If Step 1 doesn't work, Open the Command Prompt as administrator from the Windows System (Not in VS Code) > Navigate to the project path & Run that same command.
And then restart the VS Code and check!
Note: Make Sure you have installed the latest Python 3.x version
First, you should use the following command to install the discord package.
pip install discord
Secondly, maybe there are multiple python environments on your machine, please use Ctrl+Shift+P to open the command palette, then search and select Python:Select Interpreter, and select the correct interpreter.
There are two ways to be right here
Select the interpreter environment where you successfully installed the discord package earlier
Choose an interpreter environment you want to use, then create a new terminal to activate the environment, and install the discord package for your new environment.
I am on Windows 10, running python 3.8.5 and have tried installing PyPDF2 using pip. I've uninstalled and reinstalled several times using these two commands:
"python -m pip install pypdf2"
"py -3 -m pip install pypdf2"
I did this through Visual Studio code being run as my user, as well as the command prompt run as an administrator. The install goes well but I get the error, "Import 'PyPDF2' could not be resolved."
I figure this is due to the file path to the installed package not being included in the PATH system environment variable. So I used "python -m pip show pypdf2" to find the install location:
"c:\users*username*\appdata\local\programs\python\python38\lib\site-packages"
So I added:
"c:\users*username*\appdata\local\programs\python\python38\lib\site-packages\PyPDF2" to my PATH environment variable for both user and system, as well as the PYTHONPATH variable.
After such actions I restarted VS Code, which again is using the python 3.8.5 environment, and still the import could not be resolved.
What am I missing? Any assistance would be greatly appreciated.
I am using python 3.9.6. But when I typed like this in command prompt,
"pip install pypdf2"
it worked for me. Try like this sometimes it'll work.
I tried to run a python script file on Visual Studio. But the terminal keep pop up saying that I don't have the package installed... I don't know what is going on. I installed Python through homebrew and install all the package through pip3. I even find the path for all the package I have installed, and it's still not working.. I switched between multiple interpreter, and none of them worked, all said my package is not installed.. but it's clearly my package is installed... I even create a new py file to run pandas, and it worked.. Can someone help me with this? This is driving me crazy..
It just because you had chosen the wrong python environment in VSCode.
You said you had created a python file to run pandas and it worked. This means you had installed the package 'pandas' and it worked. But you haven't chosen this environment in your VSCode.
In the terminal:
By command "pip3 --version" to check which pip you are using.
By command "python3" -> "import sys; sys.executable" to check which python you are using.
By command "python3" -> "import sys; sys.path" to check which 'site-package' the interpreter searching for.
From your description, you are using the pip which under '/usr/local', install the packages under '/usr/local/lib/python3.7/site-packages', using python interpreter of '/usr/local/bin/python3'. This is the default python interpreter because of the system environment variables settings. But in VSCode you haven't chosen this environment.
Solution:
Choose an environment or create a virtual environment(recommend). Activate the environment(Ctrl+Shift+`), by the command 'pip3 --version' to check which pip3 you are using, then install the package you want to import.
If you installed python via homebrew try using homebrew to install pandas instead of pip. I've seen things before that they get linked. I would just recommend using pip to uninstall pandas first so there is only package.
I was trying to install Python3.7 package inside visual studio however I keep getting
"pip is configured with locations that require TLS/SSL, however the SSL module in Python is not available." issues, no matter what package.
The OS is windows I also tried to use CMD to pip, it seems package can be successfully installed, but it does not reflect in Visual Studio. Tried reinstall Python component in Visual Studio but with no luck.
The visual studio does have both 3.6 and 3.7 and I have Anaconda. Install package works with 3.6 in VS but not for 3.7. I really don't know where else to look for problem, could be some path configuration problem, environment variable problem?
I experienced similar symptoms and was able to find a suitable workaround.
Background:
Fresh install of Visual Studio 2019 in May 2019, no previous install of anaconda, etc. I could add pypi packages in 3.6 conda environments, but not 3.7. Attempts to install from both VS2019 and powershell would result in the ssl module error you describe.
Workaround: I was able to work around this by running pip install from the conda command prompt.
To do this, I navigated to the conda folder, which for me was at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\Microsoft\Python\Miniconda\Miniconda3-x64\Scripts.
I could run conda.exe but it errors out saying the environment isn't set up. If you modify your path to include the above directory plus several other parent and subs (miniconda3-x64 root, library, library/bin; condabin; maybe others) the error message will actually give you helpful instructions to run conda init cmd.exe or something similar to prepare your environment. You can run this for powershell as well. I ran this as admin. Close your shell and reopen, and then you can run conda activate <environment>. Once in the conda shell, I could run pip install <package> and it all worked fine, and was reflected in VS2019 view immediately.
TL;DR: Navigate to the folder where conda.exe lives; run conda init cmd.exe as admin; reopen cmd.exe; run conda activate <environment name>; run pip install <package name>; run conda deactivate; return to VS2019, verify, rejoice.
I know it's possible to run anaconda commands from anaconda prompt but it is more convenient to run it from the powershell of visual studio code like basic python where we can install the package by simply writing 'pip' command. Is there any similar way for anaconda in vscode?
If you didn't install conda to your PATH then this is by design of conda itself unfortunately.
You can just activate your conda inside a VS Code terminal:
/path/to/Anaconda3/Scripts/activate
Then you can use the same commands you can with anaconda prompt, like
conda activate env
for example