I'm fairly new to interacting with Mac OS through command line but i'm trying to make more of an effort to understand the interaction with it especially when it comes to installing programmes for programming languages. I'm trying to install jupyterlab so i ran
>>> pip install jupyterlab
and something runs so i'm assuming it has been installed somewhere.
However when then run
>>> jupyter lab or >>>jupyterlab
I get for both (command not found)
-bash: jupyterlab: command not found
Now online i've seen regarding the installation it says
"f installing using pip install --user, you must add the user-level bin directory to your PATH environment variable in order to launch jupyter lab."
Now this initially didn't mean too much to me but i've been looking into \bin files when looking at which version of python and i know
>>> which python
gives me the location of the binary for python. Naturally i tried
>>> which jupyterlab
>>> which jupyter lab
but both give me nothing.
I also get this message when i type pip install jupyterlab
Defaulting to user installation because normal site-packages is not
writeable
Requirement already satisfied: jupyterlab in
./Library/Python/2.7/lib/python/site-packages (0.33.12)
Does anyone have any ideas? Firstly do i need to add the user level bin directory to my path environment variable? If so how do i find it and how do i do that? I would really appreciate any advice broken into steps for a complete beginner. I really want to understand this so i can try to prevent issues like this in the future. I should highlight i don't have conda installed and i would like to solve this problem with pip. Thanks!
You should probably try to uninstall jupyterlab because it is installed using Python 2.7
pip uninstall jupyterlab
Then check that jupyter is non-existing by using:
which jupyterlab
And finally reinstall it using pip3 install instead of pip.
For pip to use python3.
pip3 install jupyterlab
Let me know if it worked ;)
Related
I am new to Python.
I am trying to use the Sympy package.
I am running Python 3.11 in Pycharm
I am using Windows 10.
It displays:
ModuleNotFoundError: No module named 'sympy'
I ran pip install sympy, it installed it. And when I try reinstalling it, it displays:
Requirement already satisfied: sympy in c:\users\jrk\appdata\local\programs\python\python311\lib\site-packages (1.11.1)
Requirement already satisfied: mpmath>=0.19 in c:\users\jrk\appdata\local\programs\python\python311\lib\site-packages (from sympy) (1.2.1)
I tried going through this guide
https://bobbyhadz.com/blog/python-no-module-named-sympy
but it did not work.
I tried uninstalling it and reinstalling it
both with pip and mpip
it unfortunately didnt work
at the top you can see which interpreter i am using
I can see that there is a file called sympy in my downloads folder, maybe that has to be relocated, but where to?
My instructions might be a bit rusty as I don't regularly use Windows for Python but here goes:
You'll notice that the path to your Pycharm Python interpreter (c:\Users\jrk\PycharmProjects..) is different than the path reported by pip in your error messages (c:\Users\jrk\appdata..).
It's perfectly normal to have multiple versions of Python around, but you'll need to be a bit careful about which one you're invoking.
It's unclear from your description where exactly you are running the pip commands, but usually if you open built-in terminal in Pycharm, it most likely has the right virtual environment activated automatically. The command line prompt should begin with (venv) if that is the case. If you then run pip install sympy you ought to have it installed in the correct place.
If you're using a regular command prompt, you can also manually activate the virtual environment by running the activate or activate.bat file that you'll find in c:\Users\jrk\PycharmProjects\pythonProject\venv\Scripts\ folder.
Might want to also read a bit about virtual envs # https://docs.python.org/3/library/venv.html
I found the solution. I do not know why it worked. But i moved the project from the local file on my computer to the server we use in our company, and then it worked
Try Uninstalling it and reinstalling
pip uninstall sympy
pip install sympy
I am doing this project where i need to install a package called Twint.
I want to install this package and use it's commands in my VS Code.
What happends when i for example type this in my Windows CMD?
pip3 install --user --upgrade git+https://github.com/twintproject/twint.git#origin/master#egg=twint
Because i can't type this in my VS code terminal, where i usually install packages with pip.
It will return an error that says ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?''
Now if i run this in my Windows Command it seems that i can't directly import the package in VS code?
Can anyone help me out with this confusion, where does the files get stored and how do i create good habbits around installing packages?
Hope someone understands what im struggeling with here.
Best
It is often the case that computers have more than one version of python installed and that editors like VS code use a different version than pip uses on the command line. pip installs packages where the version of python it is linked to expects them to be, but VScode doesn't know to look there.
It sounds like you have git installed where pip installs things, so you can upgrade from the command line without issue, but there's no installation of git where VScode is looking, so there's nothing to upgrade.
You either need to find where pip installs things and add it to the $PATH VScode uses, or try running a variation of python -m pip install --user git (specifying a specific url, or other things, as needed) from within VScode, which will ensure the package gets installed in a place that VScode looks for packages.
Download and Install git in your windows from here:
https://git-scm.com/download/win
Then add its installation bin path to your windows's environment path. Then you will find the git command at the command prompt globally.
This may solve you problem.
I have recently uninstalled python 3.7 and installed python 3.9. After that, when I try to use pip to install any package, it keeps trying to use python37.exe, which is not installed anymore. I was able to solve that by using python -m pip install, but the same does not work when I try to launch jupyter notebook, which still tries to use python37. I cannot launch it using a similar command python -m jupyter notebook.
I was wondering if there is any solution to this, since I could not find anything related to that.
Thanks in advance.
Maybe try to install it again using your new pip like
pip install notebook
(Sorry not enough reputation for a comment)
This usually occurs when jupyter is installed with a specific version of python. The easiest / best solution is to uninstall jupyter, then reinstall it with the correct version of python.
In your case, you should consider using python3.9 -m pip install jupyter (after first uninstalling jupyter).
Just to give you all an update in case anyone is facing the same problem.
I was able to find some remaining files and files of the previous installation of Python 3.7 in my system that were not deleted for some reason during the uninstall process. I deleted them manually and my system started to recognize Python 3.9 to call pip and jupyter after that.
I'm trying to use Jupyter notebook on a fresh install of Ubuntu 19.04. I've run through the usual installation steps, but Jupyter does not work. When I try to open a notebook, I get
500 : Internal Server Error
When I look in the terminal, I see that Jupyter has encountered the error
ImportError: cannot import name ConverterMapping
I've searched, and found questions/answers for other causes of the internal server error in Jupyter, but I cannot find a way to fix the ConverterMapping issue. I have tried uninstalling (pip uninstall ...) and reinstalling (pip install --user ...) all Jypyter-related packages, but it had no effect.
Update:
After routine system updates, the problem has returned. This indicates to me that deleting the .local directory of pip installed packages (and then reinstalling) is not necessarily a long-term fix, since it seems like automatic updates can cause the problem to re-emerge. It's also possible that some other package (installed via apt), while not explicitly relating to python, has altered the python environment in some way that breaks Jupyter notebooks.
Any ideas or suggestions would be greatly appreciated.
(answering my own question)
In my experience, these problems are usually caused by a compatibility issues between python packages installed via apt, and those installed via pip.
Unfortunately, I could not reconstruct the lengthy series of steps taken to install the jupyter/scipy/etc environment. Some packages must have been pulled in via apt and others via pip, leading to version conflicts.
This approach fixed the problem initially:
Following this answer, I ran python -c "import site; print(site.USER_BASE)" to find where pip installs --user packages
For me, this was ~/.local
I moved ~/.local to ~/.local_disabled to eliminate all locally installed packages
At this point, Jupyter worked again, (it must have been installed with the system python via apt).
I've added only a minimal subset of user packages, and will keep an eye out for incompatibilities.
I imagine avoiding pulling in Jupyter/ipython via apt might be a better way to avoid this problem in the future.
After subsequent system updates, the issue returned
This seems to confirm that the problem arises due to a mis-match between python packages installed via apt and those installed via pip. This time, to fix the issue, I:
Uninstalled python packages that were installed via apt (but not part of the core system installed with Ubuntu). This mainly included jupyter, and many of its dependencies.
Reinstalled Jupyter using pip install jupyter --user.
This is working (for now).
( Please feel free to edit/comment/extend this answer. )
The safest solution to this is to create a virtual environment and run your jupyter from it. This clearly separates all the operations of the pip and apt. It worked for me. I use Ubuntu
To create a virtual environment, run :
1)sudo pip install --upgrade virtualenv (install virtualenv)
2)virtualenv xyz --python=python3.7 (xyz is the name of the new virtual environment)
3) cd into the directory of xyz
4) source ./bin/activate
5)pip install jupyter
I had a similar experience and found Mrule's answer. The deleting/renaming .local worked for me too but his long term solution didn't sadly. So I dug a little deep to find why the first solution worked.
Turns out which jupyter returned $HOME/.local/bin/jupyter when .local was not deleted and /usr/bin/jupyter when I did. So the problem was in the pip packages (the ones installed in .local by the pip install --user jupyter option).
I had previously did sudo pip uninstall jupyter several times before, but that doesn't remove the packages in .local (see here). You have to do pip uninstall jupyter without sudo to uninstall those in the home directory (or manually delete them). I uninstalled any other jupyter related packages in my system by finding them using pip list | grep jupyter and apt list | grep jupyter.
And then finally did a fresh install of jupyter via sudo apt install jupyter. And now it seems to be working.
Bottom line is that the packages installed via pip system wide and in the home directory (.local) and that installed via apt were conflicting somehow (I couldn't find exactly why).
I recently installed python 2.7.2 on my Mac running OSX 10.6.8. Previously, I had version 2.6. I set my path in .bash_profile as follows:
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH
so that when I run python it will refer to my new installation. It does.
I would also like to use pip with my new installation, but the problem is that I already have the current version of pip installed at
/usr/local/bin/pip.
I tried to re-install pip with:
easy_install pip
But, of course this does not put pip in the desired new directory
/usr/local/share/python/pip
but simply refers to the existing version in /usr/local/bin/pip.
Can someone tell me how to fix this?
I would like to then use pip to install NumPy and SciPy in the correct directory (I was having trouble getting the SciPy installation to work with my old version of python, hence the new install).
If you'd like, you can visit the website where I found instructions for installing python 2.7, creating/updating my .bash_profile, installing pip, and NumPy and SciPy. Might provide some insight, or I'm happy to give more details if needed. Thanks!
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/#python
Install distribute as per the instructions at http://pypi.python.org/pypi/distribute .
Make sure you specify the full path to the python executable (/usr/local/share/python/python or smth in your case).
$ curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
$ /usr/local/share/python/python distribute_setup.py
Then you should have /usr/local/share/python/easy_install.
After that, run:
$ /usr/local/share/python/easy_install pip
Then you should have /usr/local/share/python/pip.
Depending on the ordering of things in your PATH, either your old, or the newly installed pip is executed when you execute the pip command, so you either might have to adapt your PATH, or specify the full path to /usr/local/share/python/pip when installing eggs.
(shameless plug:
In any case, you might consider using virtualenv for installing packages into a "project" specific isolated environment, as opposed to installing them globally.)
I needed to uninstall brew's python.
Then, I was left with python v2.7.6
Next to install, pip I ran
sudo easy_install pip
installed fine and working
I had a similar issue, try this:
$ python -m pip install --upgrade --force-reinstall pip
This will force reinstall pip with whatever version of python you use including installing the binary.
A few days ago I had a friend who was starting Python Programming and needed help with the same issue: installing pip. There are debates over which one to choose between easy_install and pip and it seems everybody is heading the pip direction. Either way, installing either of them can be frustrating.
You can use this simple tutorial : installing pip package manager the easy way
Here are what you should keep in mind as you follow the above guide:
If you already have an older version installed, uninstall it or totally remove the python installation
Once that is cleared, download an install Python.
After that, download ez_setup.py file and save it to your desktop - easily accessible from the command line
Now run it from the command line and it will install easy_install for you after which,
You can use it to install pip.
Once again, you can do this or use the above link to find a simple step-by-step guide on how to get it installed on your computer.
Good luck.
Just so that people knew, ATM we can install PIP by downloading get-pip.py from the page with docs and run it like this:
c:\python27\python.exe get-pip.py
BTW, Python 3.4 comes with PIP pre-installed.
One of the command line options lets you choose where to install to.
--install-dir (-d) install package to DIR
So something like - # easy_install pip -d /usr/local/share/python
(Please correct me if I'm wrong.)
Just wanted to say that I found a way to get around my problem. I don't know that I can explain it perfectly, since I am not very good at understanding what I am doing with this stuff just yet! But, the problem seems to have been with my PATH. I removed the PATH that I posted in my original question, and then used easy_install pip. It went straight to python 2.7.2 (my new version) with no problem. I then successfully used pip to install NumPy and SciPy in the correct location, and they both work. Thanks to ErikAllik and FakeRainBrigand for taking the time to look into it!