Anaconda new environment gives me python SyntaxError 'yield' inside async function - python-3.x

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.

Related

python versions (conda -forge)

I am using 18.04 Ubuntu with Anaconda.Recently i have trying to install OpenCV through conda-forge channel in the base environment. I did not install purposely any Python version and did not use any pip command either in base environment. Now, in the base environment, if execute just python, i get the same python version as system version and if execute python3 , i get the version installed by conda-forge. Please refer the screen shot. Python_on_Conda_base
I would like to know what is difference between python and python3 command?.What is should i keep in mind? basically i prefer the version 3.7.5 Python
.So, only the Python3 has uses different version. So, question what i should take note when i using python3 some_script.py? what is pros and cons of having this 2 version?
So far,i did not face any issues, but removed the conda-forge channel from Anaconda to avoid any conflicts. Any thoughts?
After posting this question, i have noticed python --version command gives Python 3.7.5 on Conda base environment and Ubuntu terminal (outside Conda)
You most likely have set an alias for python to point to the python3 binary.
Check this by typing type python, which will probably give you
python is aliased to ...
The crux here is that an alias will not be detected by which and as you revealed in the comments your which python returns the correct python version from your conda base environment, which makes an alias the most likely explanation, as PATH issues can be ruled out.
If above command does indeed reveal an alias, then check you .bashrc or similar file that you might have modified for a line alias python=.... Delete it, restart your terminal and everything should work normally

How to execute python program made on IDE from command prompt

I usually use pycharm for coding.
My question is how I can replace execution by IDE to command prompt execution. IDE makes it easy to set all python environments.
Windows 10 / Anaconda 3 / Python 3.7
My goal is to execute python program by windows scheduler.
Please let me know how to execute it.
Thanks.
Just open a command prompt, and then type:
python path_to_your_code/your_code.py
If this gives you errors that numpy, pandas etc are not installed then it means that the interpreter being used by your IDE (where you did not get such errors) is not the same one pointed at by python in command line.
If you're using a virtual environment or a python installation other than the default one you can just replace the python with a full path to the python binary in the environment you are using. So assuming your IDE is using the Anaconda environment, try this from command line:
c:\Anaconda3\python.exe path_to_your_code\your_code.py
Adding c:\Anaconda3 to PATH will not help if you already have another version of Python installed elsewhere, it will just mean that you now have two python.exe files in your path and python will still point at the same one.
However if where python already returns the path above, it means that your IDE is not using this interpreter and you'll need to find which one it is using. You can check this by looking in the Project Interpreter options or by running this script
import sys
print(sys.executable)

How to chose which 3.x python version on cmd?

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?

Pycharm and Python Paths on Windows with Conda

I am working with multiple versions of Python, so I don't want to put any one of them in my windows path. I discovered that I can create a virtualenv (under Settings -> Project: X -> Project Interpreter and that will allow me to specify which python exe to use, but also where to get other useful programs, like pip. The end result is that using Virtualenv I can type "pip" or "python" in the terminal in Pycharm and use it as a regular terminal.
But now I'm working with Anaconda so I don't want to use virtualenv and I want to use conda instead. This works fine, but it doesn't seem to put anything into the path. (This is particularly important because where I intend to keep my project is not near my path to the python environment conda created.)
So if I type "pip" or "python" in the pycharm terminal, it doesn't recognize them. I have to specify a huge path to get it to work right.
I've been googling around and trying to find a solution to this problem. I've found a number of supposed solutions, but so far none have worked.
So, for example, I've already tried Add Content Root under project structure. This does nothing. I've tried add local, which seems to just screw everything up. (Presumably this is a way to create a local environment that I shouldn't be touching in conda.) I've tried adding a PathConfig.pth file. So far nothing works.
Remember, I don't want to add anything into the windows path (which obviously would solve my problem) because then it won't know which specific environment I want at the moment.

Windows 7: What PATH to set to when using Conda

I've got anaconda installed and was able to create a Python 3.3 environment. I can switch to it and conda info -e shows that I've switched.
However, I'm confused about what to set my PATH variable to. If I hard code it to the exact env then it works, but I thought that the purpose of conda was to be able to switch easily, as well as update and maintain various environments separately.
Perhaps I misunderstood and there's no way around setting my PATH everytime...
In the Windows cmd shell, use the activate and deactivate commands to change the PATH automatically. For instance, if your environment is called python3, run python3 to "activate" (i.e., add to the PATH) the python3 environment. Use deactivate to remove it.

Resources