Specifically on my shiny new Surface Pro 2017 (i5, 256GB, 8GB RAM). So I'm trying to set up my dev environment and I'm running into a bit of a snag.
It shows up as installed through Powershell -and I'm able to run Python fine through it- but when I try the same on my Bash and Hyper terminals, no luck. I'm realizing now that Bash is not pictured in the screenshot, but it says the same thing when I try to run python commands. Did my due diligence in searching through the Surface subreddit, Google, and of course, Stack.
Anyone know what could be the issue?
Screenshot
In my opinion the best solution is to install python inside your bash environment, too. What is the main reason you even want to call the Windows version of python from the bash? If installing python inside the Ubuntu subsystem/the bash again, then you might try to find out the path to the python.exe inside your Windows installation and try to add these path to your bash's path, too.
Do yourself a huge favor and install Anaconda, and use command line prompt from now on and don't even Touch Powershell or bash. It's windows not linux. The reason I say anaconda is because it gives you a huge array of libraries and also you can create a virtual environment meaning if Python gets screwed on or corrupted at least your file paths will be okay.
Related
I once did something similar under windows, copying the whole python and specifying PYTHONPATH by a .bat script to make it work locally.
But today I got a Linux server that has a strict working environment and won't allow me to install anything. And unfortunately I know little about Linux. I wonder is there a similar way that I can run python on the server?
Yes, you can use python docker images for running python scripts.
I've built stand alone executables using pyinstaller. It works well. I've only used it to deliver into Linux so far.
Sorry, I cannot put a comment because of my low reputation.
In short, you cannot run a Python script directly without the interpreter installed. Fortunately, you can install a Python environment without root permission by using Miniconda (or Anaconda), then make a virtual environment and install the required packages to run your code locally for your use only.
This answer is to leave some reference for the subsequent people who encounter the similar situation.
If you choose to package via pyinstaller. Here is a good method. Almost no different from writing python. How to pack a python to exe while keeping .py source code editable?
NOTE: But there is some bad news, such as the glibc version issue. If you encounter this problem, you can refer to Pyinstaller GLIBC_2.15 not found
I started my Python journey a month ago by following a guide which recommended installing Anaconda. Since then I've written/adapted some Jupyter Notebooks using VS Code and run them from within virtual environments. Recently I needed to run one of these Notebooks via from MS Access VBA and got to understand a little about using Python from the command line - specifically about using Environment Variable Path functionality in Windows to access Anaconda\Scripts and use things like activate to active virtual environments.
In the video guide it also recommended adding Anaconda3 to my Path so I could access python.exe. However, I've held off doing this because even after plenty of reading I'm still not clear on exactly the mechanics of of using this command when working with Anaconda virtual environments.
So to my question... say I add the Anaconda3 folder to my Path and then write something like python myscript.py presumably it runs the python.exe interpreter from the Anaconda3 folder? How will this work if I'm in a virtual environment that needs Python 3.7 but the interpreter I've loaded is actually Python 3.6? Does this even matter?
Please be assured I've read for a couple of hours on this before posting my question. Happy to read more if there is a layperson guide someone can point me towards. I've read through the Anaconda site.
I have a large database of text which i want to analyze on it's sentence specificity. I want to use the tool 'Speciteller' for that, using Python. Link to the tool:
https://github.com/wjko2/Domain-Agnostic-Sentence-Specificity-Prediction/tree/master/python
One of the dependencies is to make sure to have liblinear.so. in the python/ directory. If not, i can execute a makefile - 'type make in /python' . I opened my Anaconda Prompt to execute this command, but it doesn't work. It says it is not recognized as a command, operable program or batch file.
I have already been looking how to specifically execute makefiles in Python, but i have a hard time finding the answer. Does anyone has some advice?
Note: i am still a beginner concerning Python.
Thanks in advance!
EDIT: Bump - anyone has any idea?
Edit: Operating on a Windows system
In the meantime this problem has been solved. A new update was released and additional code was provided to run it in Python smoothly. See the following repository:
https://github.com/wjko2/Domain-Agnostic-Sentence-Specificity-Prediction
A Makefile is a way to describe to a computer the steps of the compilation process of a program. To use a Makefile, on an Unix-like system (Linux, MacOS, etc.) one need to have the program make installed on their computer, and then, in a unix-shell (and not powershell like the anaconda prompt), run the command make.
However Windows does not know natively how to process those files, as the program make is not available by default on Windows. You can use a tool like WSL that let you run command designed for GNU/Linux on Windows. (I recommend installing Ubuntu 18.04). Going this route means that you will probably need to reinstall anaconda inside WSL though.
I use to have idle. Then I downloaded Anaconda and opened idle through there. I have not used idle for a while but just recently went to go open it up and use it again. However, it seems I no longer have idle on my computer, to my understanding I can still get to idle through Anaconda but I forgot how. Is there a way to open idle through Anaconda without re-downloading idle? If so what command can I use to pull Idle up?
Search for this folder "idlelib" in the Lib folder of the Anaconda version you have installed and you will find idle (check its file type: "compiled python file").
Pin it to your taskbar and run.
You are looking for C:\... <\> ...Anaconda3\Lib\idlelib\idle.bat
There is also C:\ ... <\> ...Anaconda3\Scripts\idle.exe which seems to run a little smoother, but there has to be a Command Prompt open in the background to run. ... ?
Navigate to your Anaconda3 installation folder. Yours could be anywhere, mine is at "C:\ProgramData\Anaconda3", but I installed for all users and you could have selected a random location on your drive. If you managed to add it to the environment variables you could easily find it by running the Command Prompt (not Powershell - has to be Command Prompt) and typing where conda or where anaconda and pressing enter. You should find a folder named Anaconda3 or something of that nature.
If you navigate to this folder, and within it find the "Anaconda3\Lib\idlelib\" folder, within it there is a file called "idle.bat". If you find this "Anaconda3\Lib\idlelib\idle.bat" file you can double click it to run IDLE, although it may be a little messy/outdated/glitchy/strange since you are updating all kinds of folders within Anaconda and some of them may have helped idle.bat run. Mine has a the spyder icon associated with it in the task bar and a blotted out IDLE icon in the top left corner for some reason. You could of course run the full path in command prompt as well if you already know where it is, for instance I would run...
C:\Users\Thomas>C:\ProgramData\Anaconda3\Lib\idlelib\idle.bat
~or~
C:\Users\Thomas>C:\ProgramData\Anaconda3\Scripts\idle.exe
--> It may be easier to just download a new version of Python side by side with Anaconda to run IDLE. I have been attempting to set a shortcut in the Start Menu that runs from anaconda properly for days and have failed. This way, there should be a right click>'run with IDLE' option for python files.
I believe the tilde slash (~/) was meant to imply your home directory since that is what it signifies on a linux machine, but seeing as you could have put it anywhere on the machine, even directly on the C:\ drive, maybe he meant 'unknown file path'.
If you are running MacOs (currently I am on Catalina - MacOs10.15) it is quite simple to run IDLE from Anaconda environment:
Launch Anaconda
Go to MacOs Terminal.
Type IDLE3
warning: if you type IDLE, the Python 2 IDLE will be opened ... but if you are using Python3 installed with Anaconda ... it doesn't work properly.
I have anaconda distribution installed on my macbook to my local home directory /Users/simon/anaconda
When I open up iterm and type python I see the default OSX install of python. I saw this thread here and implemented the fix mentioned: Mac using default Python despite Anaconda install
My .bash_profile currently looks like this:
export PATH="$HOME/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH"
A few strange things happen:
When I type python I still see the OSX python despite having changed my .bash_profile
If I source /Users/simon/.bash_profile this actually fixes the problem. Using python now brings up anaconda's python
When I quit iterm or restart my computer and try to load python again, it goes back to the OSX version. .bash_profile remains unchanged.
When I try all of the above using terminal everything works fine. The issues described above appear to be specific to iterm2 and I'm not sure why
How do I get my system to use anacondas python instead of the OSX version?
It seems that your $PATH is redefined somewhere else in your configuration. This usually doesn't cause issue if you know in which order they are loaded and keep track of what's going on.
I recommend a bit of reading to understand more the load order.