Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
been trying to do this for the last 3 hours with NO SUCESS at all.
I want to install Python modules in VS Code on a MAC BOOK PRO.
I enter the command pip3 install matplotlib or pip3 install keyboard AND NOTHING WORKS. This seems like the worst IDE on the planet. I keep getting the message in the terminal window of No module named 'matplotlib' when I clearly HAVE downloaded it. I'm enclosing a screen shot here.
ALSO - I Do NOT want to run in a virtual environment. I want to use the modules in any program I run. I cannot program without getting round this issue so any help would be greatly appreciated ! I am very new to Python in VS code.
Python works pretty bad for beginners IMHO, especially when people usually have no idea that both Python 2 and 3 are there (and even more minor versions on the same machines for whatever reasons).
Learn the python version being used
For your current folder opened in VSCode, 3.8.2 64 bit is used and shown in the status bar, so click it and check the popup list at top to learn what are the Python executable paths available on this machine.
You should choose /usr/bin/python3 from the list, as that's usually the default many people is using right now.
After that configuration, VSCode sticks to that executable to locate all modules and so on.
Install modules
As now you know the path of Python executable, installing a module are simply,
/usr/bin/python3 -m pip install some.module
Calling pip in this way avoid all the mess with other approaches (as they can simply install the module for another Python executable under your nose).
This should be enough to get you started on your Python journey, but far from enough to make sure you can write scripts and debug them.
Ideally, find a teacher/mentor or just someone with more Python experience than you to guide you through. Then you don't need to waste time on the tiny little things.
Managing Python versions has become somewhat of a quagmire (and some would say that's generous).
In the same way that your system will search through the folders in $PATH looking for binaries, python will search through the folders in $PYTHON_PATH looking for modules.
So you need to know:
where does pip3 install your modules?
is that in echo $PYTHON_PATH?
More info here:
https://stackoverflow.com/a/65164141/10761353
https://stackoverflow.com/a/53566561/10761353
Failing that, pyenv is a tool that help manage multiple python versions in a system (I just started dabbling with this last night myself). Basically you would do something like:
install pyenv
use pyenv to (e.g.) pyenv install 3.9.6
define your global python versions pyenv global 3.9.6
One can install pyenv from Homebrew: https://github.com/pyenv/pyenv#homebrew-on-macos
Try running which python3 in the terminal. In mac the default python is installed in /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.
So if you install package with pip3 it will be installed in Location: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-package. And according to your posted image you are running your program with /usr/bin/python3 which is unable to find the installed packages.
Related
I'm a python noob working through this intro to python: https://www.youtube.com/watch?v=rfscVS0vtbw. (definitely no need to watch this. Just adding it as context)
It's been going really well, except now I'm up to the part where I need to use pip, and despite having downloaded version 3.8 of Python, it keeps telling me that it doesn't even have pip installed.
I'm wondering if anyone could walk me through what the issue might be and how to actually start using pip in PyCharm.
I've tried downloading pip and installing it but even that doesn't seem to work. If anyone has an ultra-hand-holdy solution (very much for a noob) that would be appreciated.
I feel like the problem might be that I'm putting things in the wrong directories or something? Obviously there are some built-in versions on Python (2.x) already on the Mac so maybe they are interfering?
Thanks in advance for your help.
If I recall correctly, the version of Python that is used when you use the command python is the 2.x version, which doesn't have pip. So if you want to use python in terminal, you should call it as python3 and pip3 for using the pip command.
If you want to set a different Python version as the default one, you can do that. Here is a tutorial that can get you started with that (there's a plethora of other tutorials if this one isn't clear enough): https://opensource.com/article/19/5/python-3-default-mac
For using PyCharm specifically, you can setup the Python interpreter that is used with PyCharm by going to Preferences(or Settings) -> Project:[name of your project] -> Project Interpreter and then chose the desired Python Interpreter from the drop down menu. You can also create a virtual environment there by clicking on the cog icon and choosing Add. This is the preferred way and very convenient to keep installed packages local to your project. After you're done with that, open up PyCharms terminal (at the bottom of your PyCharm window) and you should be able to normally use pip with the command pip.
Alternatively, you can install Python packages in PyCharm using their built in package manager that you can find in the same window where you set your Python Interpreter. Below the dropdown menu you'll see a + sign, where you can click to add packages.
I ran into the same problem as here. So I tried to install python developer package but I didn't find the way to do this.
Cython's helloworld instruction doesn't contain any info about it, which seems strange and stupid to me to not include basic requirements into instruction, named "Basic Tutorial" (Sorry if I don't get something about it.)
Anyway... I'm using Windows 10, PyCharm, virtual environment with python 3. When I went to package install window, search result contained 5 packages:
So, which one?
I tried to install one, but it gives me an error:
I met this error in the past with some other package already. PyCharm's suggestion is to run that command from terminal. But from my experience that never helped. Usually solution was either to change name (because some names are right for Python 2.x, other for Python 3.x), or to download the package (egg/wheel) manually and install it offline.
This question was asked before already, but that one is for linux, which is not the case for me.
Can someone save some time for me and future generations, please? ;)
How do I install it and make Cython's helloworld example work?
In this SO post I outlined my problems, and I would like to try and solve them by getting rid of all my downloaded python launchers, modules, versions, pip etc (for python 2 & 3) and start afresh. My only problem is that macOS comes pre-loaded with python 2 and I don't think I can or should get rid of that, but I do have other versions of python 2 installed that I do want to delete.
Is there any help that you can offer that will tell me what to delete and what not to?
Should I need to use 'sudo' at all during my uninstalling?
Are there any tests to ensure certain things are completely gone?
Please keep answers fairly simple to understand implement.
When I reinstall the things I need, is it better to do it all via home-brew, then pip; instead of downloading from safari, unless necessary?
If you installed using sudo (or typed your password into an installer), you'll need this to uninstall too. Mac python is in /usr/bin/python and /usr/lib/python*. Yes it can be good to install via homebrew, although I've had good success with the Anaconda distro of Python. The important thing is setting you PATH and PYTHONPATH variables in ~/.profile or ~/.bash_profile so that it sees your custom installed Python before it sees the system install.
I'm running openSUSE 13.2. I already had python 2.7.8 and python 3.4.x. I ran into a situation where a business server was running python 2.6. I wanted to make a virtualenv, but I need to install the specific version first. I couldn't find python 2.6 in yast and I wasn't getting any hits when I was search for stuff in zypper.
So I downloaded the tar ball from python's download page for python 2.6.6 and followed the directions in the readme
./configure
sudo make install
This worked, but it changed my default python interpreter in the process. I worked through that and now things are fine. But I might want to install a different python version in the future without having to worry about it changing my default interpreter. I'm pretty sure there's more I could do on my own, but I need to move on to something else and I'm wondering if anybody was some quick feedback on what I've done so far and what I should do in the future.
If you need to maintain distinct versions simultaneously, it's best to install each in its own tree. configure takes an optional --prefix=/path/to/installation/root argument.
At one site, we would install an add-on software package in something like /opt/local/x86_64-linux-gnu/python-2.6.6. Users who need this specific version can then add /opt/local/x86_64-linux-gnu/python-2.6.6/bin to their $PATH, or use virtualenv or GNU stow.
I've been going with a basic Python3.4 install that I've been installing many modules into for over the past month but have reached a point where pip is coming up short and I'm going to just install the full Anaconda on my system to go deeper into bokeh-server stuff.
I get a popup during the Windows 64bit installer (Anaconda3-2.3.0-Windows-x86_64.exe) saying
A version of Python 3.4 (64-bit) is already at C:\Python34\ We
recommend that if you want Anaconda registered as your system Python,
you unregister this Python first. If you really know this is what you
want, click OK, otherwise click cancel to continue.
Didn't find much documentation on this subject, and I'm not really sure how to "unregister" that installation of Python apart from uninstalling it entirely from Windows which I imagine would accomplish such a thing. Is this basically telling me to check how my Python Launcher for Windows is setup after the Anaconda installation? I'm completely unfamiliar with this notion of python system registration? Is that just a round about warning about which python version takes precedence on the system path, or which installation holds the file associations?
The solution is simply to uninstall python (for example, run the original python installer and select the uninstall option). The python key in the windows registry will be removed (which is what unregister means in this context).
Here is a link to a script that will unregister a Python installation (if you haven't come across it already). I personally have not dealt with anything like this. It seems like it should work, but you may have to tinker around with some of the paths in the script to get things to work. The links in #nightuser 's post will also probably fix the issue.
Why not just remove your version of Python? You could do a pip freeze > requirements.txt with your current Python and add them to Anaconda, or create an environment with Anaconda using those packages. Anaconda has greatly decreased the amount of time I spend setting things up.
You are getting that prompt because you have another version already installed the safe way to do this is going to the directory of the existing version and running the uninstaller. Once the previous version is completely uninstalled. You can run the installation as normal it should works!
enter image description hereYou have already installed python in your environment, so your system can handle your python code. Anaconda can handle your python code as well. If you install Anaconda and expect use python provided by Anaconda, then your system will confuse about assigning the code job. To avoid this confusion, there is always a path to point out which python you want.
You can ask your OS to find specific python by changing your environment path in windows OS:
By deleting the python path your Python will be invisible. Changing path is more convenient compared with the uninstall.
If you got a python compiling software like Pycharm, things are different. Pycharm may have python3.6 while your system got python 3.5. You need to delete path in those software or uninstall python specified by those software.
Pycharm
Actually, instead of registering the Anaconda as the system python, you can install it first, then specify your Pycharm and system path to the Anaconda python path. Thus, your Pycharm will use python provided by Anaconda and package & virtual environment you need.
I edit this for lots of times because I got Great wall, so I can't close something pop up in my screen(cause it is Blank). And everything is missing if I refresh. This is annoying.
My system path Anaconda3's python36
Add path in Pycharm
Or you can't use these packages and Anacon's virtual Environment