I have some code working with python 3.6.6 but I have 3.7.2 in enviroment too.When I try to run my code in cmd, it's trying to run with 3.7.2.How can I chance it?
There are a couple of ways you can tell a script to run with a specific version of Python, commonly you'd use a shebang:
#!/user/bin/env/python3.x
However, I think this only works for Linux/Mac which it sounds like you aren't on if you're referring to cmd. You may want to check out this answer which has a few other options that may help: How do I tell a Python script to use a particular version
Alternatively you can set up a virtual environment, which allows you to run different versions of Python, modules and any other environment settings for a specific project. If that sounds like a better solution then this answer should help you out: (Easiest) Way to use Python 3.6 and 3.7 on same computer?
Related
I'm new to Python, but I have set up an python script for searching some specific Values in 2 different excel sheets printing out matches (in excel).
Problem is, that our work machines are heavily locked down and without admin privileges, we can't really install anything (we can download though). Is there any version of Python that is Windows 7 compatible that will run standalone without requiring any sort of installer?
I have tried pyInstaller, but the problem is that in my script we need PANDAS.
And there is no possibility to pip install pandas to our local machines. All is blocked. ("pip install pandas" is not possible. I did the code with Anaconda)
So my question is: how can I set up a file for my coworkers, who have no permission to download pandas?
Can I set up an exe file (all use windows 7/10) in my private computer where pandas is already installed and forward it to the workers?
It should be very easy for them to use--> double click for executing the python script
Thanks in advance for any advice.
You can also use pyinstaller which personally I find the easiest to use. It can bundle executables for both Linux and Windows, but it must be run on that architecture that you wish to have executable for, i.e. if you want to have Linux executable the pyinstaller command with your code must be run on Linux OS of some kind.
More here: https://www.pyinstaller.org/
This is old so you may already have found a solution but this might help others.
Python by default is an interpreted language. This means that compiling it into an .exe file is impossible.
However, using some modules it is indeed possible to convert a .py script into a windows executable.
You can try py2exe.
py2exe is a Python Distutils extension which converts Python scripts
into executable Windows programs, able to run without requiring a
Python installation.
They have a tutorial here.
Here is what I get when I run the following commands in my terminal:
python --version
python 2.7.1
python3 --version
python 3.7.3
I ran the 'Update Shell Profile.command' file that comes with the Python3 download, but it still doesn't change the value of
python version
when I run it. My question is, is this normal? Does it change anything important other than needing to type 'python3 file.py' to run 'file.py'? If so, how do I change this? (Also, the computer I am using uses Homebrew which I am not familiar with, I am not sure if this changes anything or how.)
Python 2.7 and Python 3.7 are the latest releases of python 2 and 3 repsectively. Those two are two different version which can co-exist together. You can have both versions installed in your computer at the same time. If u dont like that just uninstall one(I'd suggest python2). The main difference is that python 3 offers many advantages compared to python 2. Some of them would be that some libraries work only for that version other legacy ones work for the other version etc. So there is no problem with having both but like i said there is really no point. Just choose whch version u like and uninstall the other one.
In advance, sorry if this is question ought be on SuperUser or another site
The python3 shebang doesn't seem to work on win10. (I cant check right now, but I believe the analogous approach worked on MacOS for me last night). Consider the following
#!/usr/bin/env python3
print("hello world")
Leads to the error 'python' is not recognized as an internal or external command,
operable program or batch file. This makes sense because I only have a python3 distro on my machine (which can only be called like python3). However, Atom seems to be ignoring the shebang altogether. FYI, I'm running the script with the popular "script" atom package.
I've tried the permutation, #!/usr/bin python3, but this doesn't work either.
I've tried permutations
I'm still interested in how shebangs work within the Atom environment, but as far as getting python3 up and running, you dont need a shebang. You can simply change a config file (python.coffee) from within Atom, then relaunch. See Daniel Chamorro's excellent answer here: How to setup Atom's script to run Python 3.x scripts? May the combination with Windows 7 Pro x64 be the issue?
Ok, I'm sorry if this has been asked before, I did found some info here but I'm still stuck.
I have Anaconda 3 (python 3.6) on Windows.
Created a new environment using
conda create --tf python=3.5
That works just fine and in cmd I can activate it. But I get this nice error when running python.
I kind of get the idea my issue is my win environment variables.
But I have tried to added my Anaconda path to the beginning of my path variable and my new tf environment path to the beginning. But no luck. Is this some sort of conflict between python 3.6 and 3.5.
Thanks
[Moved from comments]
Somehow or other you're trying to import from your root install even within your activated env, and that root install (being Python 3.6) uses async + yield in its stdlib, which isn't supported in the 3.5 you want to use.
When using Anaconda, you shouldn't have either PYTHONPATH or PYTHONHOME set (and if there are other PYTHON* environment variables set, might as well clear them too!)
These cause problems because these variables are very powerful and the interpreter winds up obeying them. In the case of multiple environments and/or multiple Python distributions on the same system, it's best to leave them alone.
I'm trying to use the app wapiti to make some security test in a web project running in localhost, but i have some problems with the syntax of Python. I follow the instructions that they give in wapiti project site and write this:
C:\Python27\python C:\Wapiti\wapiti.py http://server.com/base/url/
but i get this:
SintaxError: Invalid Sintax
I had read that the syntax of python changed in that version... I really need help please.
Looks like Wapiti prefers Python 2.3. I'm judging by Wapiti's copyright date of 2006 and a note in its manual that one of its options doesn't work in Python 2.4.
You can simply install Python 2.3. If it's within your skills, you might want to install it in a virtual machine or a Python virtualenv.
Do this setting first
Go to control panel->system security->system->Advance system settings->click Environmentvariables--> change the path in listbox->
variable value =;C:\Python27\ concatenate this with actual text..
run command prompt
go to wapiti file path
example:
D:\wapiti\wapiti-2.2.1\src\python wapiti.py http://domainname.com/ -[options]
D:\wapiti\wapiti-2.2.1\src\python wapiti.py http://domainname.com/ -s
D:\wapiti\wapiti-2.2.1\src\python wapiti.py http://domainname.com/ -h