How to change the path in google colab? - python

I'm currently working on getting better acquainted with Google Colab and using it as a coding environment with python. I'm trying to setup an ipynb script for testing. As part of this, I'm trying to install pipenv. I'm following the directions from (https://docs.python-guide.org/dev/virtualenvs/#lower-level-virtualenv)
Part of the directions state to change the path from ~/.local to ~/.local/bin. I ran command: "!python -m site --user.base" to determine the path, and it returned "/root/.local" I'm not very familiar with Colab so I don't know if a bin file already exist or if I need to make one or something. I'm also unsure of whats the safest and what best practices should be followed with respect to Colab when setting the path. Typically I modify the path on my windows machine via the GUI, and I've never had to change it using the command line before. Thanks in advance to anyone who knows how to do this.

Okay, here is a copy of the error message I was getting from Google Collaboratory while trying to install pipenv:
WARNING: The script virtualenv is installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script virtualenv-clone is installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts pipenv and pipenv-resolver are installed in '/root/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Since I wasn't really sure what these warnings meant, I ran the pipenv install command anyway:
!pipenv install requests
This resulted in an error message basically saying the the command pipenv could not be found.
I don't have any experience setting path variables in Colab or from the command line for that matter, so I reviewed the following stackoverflow question from another user [link]: How can I insert path (environmental variable) for geckodriver in goggle colab? to try and get an idea of how to go about it. After reviewing it, I ran the following command:
!cp /root/.local/bin /usr/local
This resulted in an auto comment:
cp: -r not specified; omitting directory '/root/.local/bin'
As I said before, I don't have any experience with setting system variables from command line, and everything I've every read about it comes with a warning saying something like: failure to do it properly can permanently damage your machine. So I was hesitant to just tack on the "-r" flag.
After doing a web search I found a good explanation of the -r (recursive copy) flag from this site [link]:https://superuser.com/questions/839719/why-is-r-recursive-necessary-when-copying-a-directory-in-linux/839749 and I ran the following command:
!cp -r /root/.local/bin /usr/local
This ran without incident and I called:
!pipenv install requests
Success! It ran without incident.
Since I want to save my results from the script I'm writing, I had previously mounted a virtual drive using:
from google.colab import drive
from google.colab import files
drive.mount('/content/drive')
I also created a new directory in my google drive to hold this script and any future data files etc... I was not in the directory when I ran the above code and I don't know if that will be a problem. I'm not really familiar with Python and its virtual environments. If anyone does know if this will be an issue, please feel free to message me. Thank you to everyone who read this question and attempted to answer, or even contemplated what the answer could be.

Related

installation problem with epftoolbox in python

I have absolute no further idea, how i could manage the installation of the epftoolbox in python. I have tried the steps from https://epftoolbox.readthedocs.io/en/latest/modules/started.html in various ways and directions, but it still doesn't work and i get the following error when running the file:
ModuleNotFoundError: No module named 'epftoolbox.evaluation'
Can anyone suggest a step by step video or something like that, where the installation is showed for 'dummies'?
Any help would be veeeeery appreciated!
PS: I'm working with pycharm
Since you're working with pycharm first create a new project with a virtual environment and open the terminal and type the following clone statement : git clone https://github.com/jeslago/epftoolbox.git
then move to the cloned directory by typing this command:
cd epftoolbox
once your'e inside this directory run your pip install command:
pip install .
you should be able to work with the library here.
since you already created the virtual environment..
Hope it solved your problem.

Moved the Python installation - python runs, but ipython, flask, juypter, oldvba do not run - error in launcher

Moved my python installation to a new folder to eliminate space from username path
Updated the PATH variable to reflect the changes.
Re-run pip which fixed itself.
Running any thing like ipython, olevba, jupyter, oledir returns similar to
Fatal error in launcher: Unable to create process using '"c:\users\username\appdata\local\programs\python\python39\python.exe" "C:\Python\Python39\Scripts\oledir.exe" ': The system cannot find the file specified.
I've been through the Windows 10 registry and amended several obvious errors but I still can't fathom what else I am missing.
Ideas please.
Thanks
In the end ran a pip freeze > requirements.txt. Copied that somewhere safe.
Delete the entire Python directory
Downloaded and ran the Python install (and upgraded to 3.9.6) which recognized my preferred installation folder and installed accordingly.
Ran pip install -r requirements.txt (which seemed to copy most from cache elsewhere)
Everything now works.

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings

I was trying to download a GUI, but the terminal kept giving me this error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
I'm trying to install it using this command:
python -m pip install --upgrade pip setuptools virtualenv
Check your Python version and be sure it is installed on your machine
Check the path environment variable
Go to -> "start" and type "Manage App Execution Aliases". Go to it and turn off "Python"
I was having the same issue and I fixed it by using the below method.
Copy two paths of Python
C:\Users\Maninder\AppData\Local\Programs\Python\Python39
C:\Users\Maninder\AppData\Local\Programs\Python\Python39\Scripts
These are the paths where your Python interpreter is installed. Now add this path into your environmental
variable. Put this path into System variable, not in user variable. I was using user variable, so I was facing the issue.
I have a solution for you. Make sure you check the path mark during installation. Then you need to go to Manage App Execution Aliases.
Simply go to your search bar and search for Manage App Execution Aliases. You will find the attached screen and you need to turn off App Installers as you see on the screen. Also, see the path,,, follow Maninder's answer.
Then you are good to go! :)
I had the same issue. In Windows CMD, only: py --version, works.
I tried adding the path on System variables, and it didn't work. If you are using PyCharm as I do, try to run all commands from the IDE's terminal. It usually is on the side bar where the Run and the Console is. If it is not, go to: menu View → Tool Windows → Terminal. It worked just fine for me.
You need to download Python from https://python.org. When in the installation, be sure to check the option that adds Python to PATH.
I haven't gotten this error before and have been using Python a long time, and then suddenly it showed up. I think that it is a result of a Windows update designed to steer you to their store.
In any case: to remedy the problem, go to Settings → app execution aliases → and turn "off" Python. (What they tell you to do, in other words). This should resolve the problem.
If you have installed Python successfully with add python path, ticked on, and have added
C:\Users\<user>\AppData\Local\Programs\Python\Python39
C:\Users\<user>\AppData\Local\Programs\Python\Python39\Scripts
to the path into System variables and have turned off the "aliases" and they all didn't work, you can simply use python instead of python3 in your cmd command.
Check the Aliases for App Execution in Windows. Search for Alias App in your Windows toolbar to find the UI for this. Try turning off anything Python related.
Try adding the following to your "Path" environment variable:
C:\Users\Default\AppData\Local\Programs\Python\Python37
C:\Users\Default\AppData\Local\Programs\Python\Python37\Scripts
Replace Python37 with your own version.
I solved this problem for Visual Studio Code with just writing "python" in the console:
python
After that, Microsoft Store opens automatically with the Python app:
And I just click Get.
And it all work!
All the previous answers are correct, but in my case, I was getting this, because I was not passing the version...
The fix is passing the version:
py.exe -3 your_program
If you're on Windows, you may want to use the Python installer, in Windows Marketplace.
I faced the same error while using Anaconda and trying to link the Python executable path in the command prompt.
It got rectified by going to Settings → App execution aliases → and turning "off" Python. Then again I had to set the path for Python in Anaconda and was successful in executing "python --version" command.
The same thing happened to me even after trying all the above-mentioned steps.
I just restart my system and it was working fine. Do it and if still doesn't fix the issue then make sure you have checked "add python ( any version ) to PATH" before installing Python.
If none of the previous answers are working, you can check if you have the Python executable in your program files.
Go to C:\Program Files and check if you have the Python application. If not, go to the python download website here and download the .exe file.
While installing you must select "Custom install" and select the location as C:/Program Files.
Install it and it should work now from anywhere. This worked for me!
To sincerely resolve this issue, do the following:
Uninstall the Python instance and reinstall it. Note: Make sure you check
"Add variable PATH".
On the command line, type:
python -m pip install --upgrade pip setuptools virtualenv
I got this issue when I used Visual Studio Code as the IDE, and Anaconda as my Python compiler. And you don't need to close the "app alias" in settings, but copy your python.exe to python3.exe in your Anaconda folder.
That happened to me. So, to fix it, you have to follow the following steps:
Uninstall the Python version you already installed.
Go ahead and open the installation file to reinstall it again.
Before hitting Install Now, make sure to tick the box in front of Add Python to path.
Go ahead and complete the installation procedure as usual.
Steps for installing Python
The problem is more subtle than it seems.
For example, if you are using Visual Studio Code on the bottom left, you should see Python X.X.X xx-bit (the X is the version).
If you click in there you will see where the IDE is getting the python.exe from.
Locate that folder into your file explorer and then just follow the answer that is saying to change the environments variables.
So copy the path where python.exe is and add it to the Path variable and do the same where the Script folder is (it is in the same directory where the python.exe is).
Then of course make sure your IDE is using the right Python.
None of the answers here worked for me. I did this and the error went away.
For Windows 11 which I was using, I reran the python-3.10.5-amd64.exe file from my downloads directory and then chose to modify the installation.
Then I followed these easy steps.
Make sure the PIP component is checked before proceeding to install.
Then check 'Add Python to environment variables' if it's not checked already.
Proceed to Install.
At this point, your error will be solved
If you already have the Python executable on your machine and you are getting this error in Windows 10, search for the Python executable and copy its path then copy the path in system variables. It worked for me.
to check in windows
py --version
or restart your pc first then put htis command again
I was also facing this issue after installing python, while running command
python --version in command prompt , error as:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
So, i too added
the path in environment variable as shown, and it worked:

Pip Python Installation Issues

I'm pretty new to the community, and new to python. I know the basics. But now I'm trying to download third party modules via pip but everything I do regarding pip displays an error. I know that pip comes with python seeing as the pip file is there.
I am running python 3.6 and windows 10. I have downloaded pip off the internet also but when I try to run the program it says already downloaded. The first time I ran it it said that it was downloading and successfully downloaded so I'm kind of lost.
Thanks!
Sounds like it's already properly installed. pip is a program called from a system terminal, not from a Python prompt. Open up a command prompt and type pip -h see what happens. If this does not print out the help page on how to use pip, and instead you get an error to the effect of:
"pip" is not recognized as an internal or external command, operable program or batch file
You then need to point Windows where to find the program (pip.exe) by adding your Python scripts folder C:\...\Python36-32\Scripts\ to your environment PATH variable. To do this, open the Start menu and search for "environment variables". Open the dialogue and find one named PATH (case doesn't matter). If it doesn't exist, create it. Edit the value and add the file path to the scripts folder to the end using ; as a separator.
As per your comment, if you are getting an access denied windows error this answer from another question may help you.
You need need to be sure either your powershell is being run as administrator, or by creating a virtual environment.
The Installing Packages docs have a great overview, and instructions.
https://packaging.python.org/installing/#use-pip-for-installing

Gitstats Eclipse

While working in Eclipse with .git is noticed Eclipse makes a nice folder for gitstats in the project folder.
I attemted to use these files to generate gitstats output, but i cant seem to get it done.
Can someone explain to me how to use these files to get gitstats output.
I do have Python, Gnuplot and git installed. All the latest version.
I do understand that i somehow have to run python on the gitstats file. But after hours of trying is still cant manage to find out how. Probably I am doing something simpel wrong cause i cant find much information on how to use GitStats, any help much appreciated.
You should not put the gitstats repository under your project directory (I'm assuming the upper screenshot is of your project directory). You can clone it to a separate directory, and then pass your personal project directory as a parameter, as the doc/INSTALL instructs:
./gitstats /mnt/src/git/project ~/public_html/project
That is a command that needs to be run in a terminal/shell. Of course, you could add an External Tools Configuration in eclipse for it, but not sure if it's worth the trouble, unless you want to run it very often.
After some hours i finnaly got it working, since i noticed some people had the same issue here the solution.
Eclipse wil just clone your git repository as you would with git it self.
When using gitstats make sure you install python27 and not python33.
Set up your PATH variables to python27 files.
Install GNUplot and also add the PATH variable.
If you use windows insted of linux, in order to easely use gitstats run it in git bash. Since gitbash is Shell script and does suppor WC. CMD does not support WC unless you got Unix installed.
If you still have issues running gitbash, recheck PATH varaibles since that is 9 out of 10 times the issue.
Enjoy!

Categories