I'm pretty new to programming, and very new to doing so in a UNIX environment, so please bear with me.
When I run
import sys
sys.executable
in my Python 3 console, the output is
usr\bin\python3
and I'm able to import whatever libraries I've installed with pip3, no problem. When I do so in my Jupyter Notebook running a Python 3 kernel, the output is
usr\bin\python
and the libraries that I've installed with pip3 are inaccessible to me. What can I do to fix it so Jupyter is executing Python from the right place so I can use anything I've installed for Python 3 with pip3?
Thank you!
Go to This PC → Right-click → Click on Properties → Advanced System Settings. You will see the System Properties. From here navigate to the Advanced Tab -> Click on Environment Variables. You will see a top half for the user variables and the bottom half for System variables.
Making an Executable file with PyInstaller The first option offers a nice GUI (graphical user interface) that takes care of all the stuff necessary to convert your Python script into an executable file.
In this article, you will learn how you can convert .py file to .exe file. Follow the below steps for the same. Install the library pyinstaller. Type below command in the command prompt. Go into the directory where your ‘.py’ file is located. Press the shift⇧ button and simultaneously right-click at the same location.
The first (auto-py-to-exe) has a friendly interface that will help beginners to easily create executables, while the second (PyInstaller) offers a straightforward way to create executables through the terminal. 1. Making an Executable file with auto-py-to-exe - Step 3. Choosing “Console Based” or “Window Based” 2.
The solution is to use virtualenv: create an isolated Python 3 environment (with the -p python3 option), activate it, and you're good to go. Correct system tools use #!/path/to/python shebang. So they don't break. But you're right python should start 2.x python executable.
Short
You need to register your Python kernel with Jupyter, for it to find the "right" Python
Long
Jupyter is meant to work with multiple kernels, and languages; it is common for some users to have tens of kernels, many can be the same language, with small differences. You usually need to "tell" jupyter about these kernels, it is often referred to as "Installing a kernelspec". In your case you need to:
You'll find instruction on above link, a few tip though:
python
by /full/path/to/python
if you are unsure. pip
, you can always replace pip
(or pip3
) by /full/path/to/python -m pip
to use the pip linked to the python you want. sudo
, don't. People telling you to use sudo get issues after a few month when their linux distribution need to be updated – unless you really know what you're doing. Once you've registered the Python kernel with Jupyter, it should just appear in the menus. You may need to refresh your browser though.
Enjoy !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With