I am a beginner to coding in general and I just found out that we could create virtual environments and was soon disappointed to see that there was no tutorial or answer anywhere for a Windows user and the only one I found was THIS. Which kinda solves my problem but isn't ideal. And I wanted to follow forms that actually SOLVED my problem but they were for mac and linux users. So can someone help me out?
Thanks in advance !!!
It is mentioned in the docs:
For virtualenv created environments to be discoverable by SublimeREPL
they should be created or symlinked in one of the following:
~/.virtualenvs default for virtualenvwrapper
~/.venvs default for venv
Alternatively, more paths can be added to “python_virtualenv_paths” in
the SublimeREPL configuration file.
If your virtualenvs are created in another directory add them to SublimeREPL.sublime-settings. For me, they are in ~/Envs:
{
"python_virtualenv_paths": ["C:\\Users\\my_username\\Envs"]
}
Assuming you're using the correct path, sublimeREPL: Python - virtualenv allows you to select the venv you want to work with:
Related
TL;DR
This question is NOT asking how to select a Python Interpreter to run, or debug, code with, furthermore; this question is NOT asking anything in regard to Virtual Environment, or how to activate a Virtual Environment, all of that is working. I feel it is important to note, that the question below has been asked previously, but failed to receive a satisfying answer due to confusion over what was being asked. Community Members often think one of the questions, that I mentioned at the beginning of this question, is being asked, here is a question that's a good example of what I just wrote here.
Here is My Question:
How can a user configure their Integrated Terminal to use an Interpreter that the user specifies?
I want to be able to configure my terminal to use the interpreter in my virtual environment — their is an example of my virtual environments interpreter in the Screenshot below.
from the status bar that the VENV interpreter is active, and my code runs fine.
from the Windows Terminal the system interpreter is being used.
The problem that is caused by this, is that I can't run pip or other packages like PyInstaller from the Integrated Terminal because its not looking inside of my VENV, and furthermore; I don't want to globally install the packages.
Another problem that occurs is that, parts of my app include version sensitive packages, and I need to control the version of the python interpreter used by the Integrated Terminal.
I know this doesnt really answer the question but it may be of some help to some people, so here it is.
I have no idea what im doing but I finally fixed this issue...
my issue was that I was trying to get the default interpreter to use python 3 instead of python 2.
I ended up deleting python 2 from my PATH...
in the end I realized that the path changed to this after I deleted Python 2, so maybe the solution can be found here.
maybe this?
{
"python.pythonPath": "C:\Users\T\AppData\Local\Programs\Python\Python310\python.exe",
"window.zoomLevel": 0,
"python.defaultInterpreterPath": "C:\Users\T\AppData\Local\Programs\Python\Python310\python.exe"
}
I want to install Eric with pip into a Linux environment set up with pyenv. The program works, but I can not see my packages. I can not see what the problem is.
Here is what I did
I installed eric into a virtualenv "eric6" usind pip install eric-ide. That worked fine.
I run eric from a direkt link to the executable in the .pyenv folder.
I add a new virtualenv
pyenv virtualenv 3.6.9 default
pyenv activate default
pip install numpy
Now start Eric, start a program with the line import numpy and you will get a ModuleFileNotFound error. Programs with no external modules work fine.
The PyPI page will not show the same list for "default" than pip list on the command line.
What could be the problem?
Eric-IDE is a great and fully open source environment for Python. It has stunningly comfortable and widely configurable features and offers a perfect workflow while being rather intuitive to use. Really a full blown IDE. Although I am not using QT (where it offers even more integration features) I am really glad to resolve this major show stopper I came across which was issues with pyenv. I found the solution for my problems and now can answer my own question. Maybe its useful for others.
Eric-IDE can be used well with pyenv in Linux.
Install Eric into an own virtualenv. And your programs in others. At least there is no need to install Eric into the OS system.
Eric has 2 dialogs in the "extra" menu dealing with Virtual Envs and one PyPI Window where your can list the installed packages per virtual env.
The "Manager"
Eric only recognizes automatically on virtualevn. This is the one where eric was installed.
This is named , but you may change the name. I change it to "eric" in my installations to avod confusion. There is one setting in the related Edit Dialog saying "Global Environment". For the virtualenv where Eric is installed this is checked and works, even though its actually not the global (=system) environment. Maybe the change that in versions after 20.5, because it would be more logical if that checkbox would be unchecked.
Use the Add button to enter data of other virtual environments you have on your system. It does matter which folders you enter as it might not see your packets when you entered the wrong folder (e.g. wrong folder for the "Interpreter"). Following is what is correct for a standard pyenv virtualenv created with "pyenv virtualevn 2.8.18 pythonLegacy" in Ubuntu 18.04. When you point the Interpreter path to the actual python installation Eric will not see your packages. It only works if you point to the symlink as in the example.
Logical Name pythonLegacy
Directory
/home/user/.pyenv/versions/pythonLegacy/lib/python2.7/site-packages
Python Interpreter /home/user/.pyenv/versions/pythonLegacy/bin/python2.7
All options unchecked
PATH Prefix <empty>
if you add the OS system environment you must check the "Global Environment" checkbox. It will work as expected.
The "Configuration"
the name is misleading, because this dialog allows you to create a new virtual env from within Eric IDE.
Please be careful what you enter, because it will write (or overwrite) data in your pyenv folder. As there is not documentation about this dialog, its a good idea to backup your " ~/.pyenv" (or whatever) pyenv home folder before testing what settings it needs.
PS: I would hope more people start using this, so the default Ubuntu repositories would start upgrading the package. Currently it is not among the maintained ones.
I am a beginner trying to learn a bit of Python; first practical applications will be data analytics. My learning setup consists of Mac OS X, Miniconda2, Pycharm and Git.
Is it better to set up a project folder 'bar' within a conda environment folder 'foo' (~/miniconda2/env/foo/bar)?
Or is it better to leave the conda environment alone as ~/miniconda2/env/foo and set up a project folder as ~/repos/bar?
Virtualenv users I've seen put the env and the project in a single folder, but I have not seen a similar, popular or recommended workflow for conda.
Thank you in advance for any advice.
While I haven't used conda myself, I expect they aren't trying to change the concept of a virtual environment too much. That being said, I personally find it better to keep them separate, i.e. have a ~/.virtualenvs and a ~/repos folder.
As you mentioned, though, it's pretty common to store both the virtualenv and the project itself in the same folder. What I would stress here is that the virtualenv should then be in the project folder, not the other way around. For example:
~/repos/Foo/.fooenv
The reason for this is that virtualenvs should be disposable, whereas your projects are not. That means that you should be able to freely remove a virtualenv without fearing you've accidentally deleted your project folder along with it.
I created a django project and its interpreter is an 3.5.2 ENV, all the extensions that I install in Pycharm it doesn't recognize them, when I try to add them in Installed APPS, they aren't available.
But if the interpreter is only python.exe it recognizes.
So, How do I change the intrepeter of a project that is set to the 3.5 2 ENV to another, I don't know exatly what ENV is, and why it doesn't allow me to use installed extensions.
Go to preferences then project. You can set the interpreter there.
I assume the ENV you are talking about is a virtual environment. You normally create your project inside a virtual environment in order to maintain project-specific dependencies. E.g. If you install a dependency in your virtual environment, it can be accessed ONLY from that container. So, it is not installed system-wide and therefore cannot be accessed by things outside of the ENV.
Makes sense because you don't really want to install project specific things system-wide. E.g. what if you wanted to work on one project with Django 1.10 and another with 1.8? You would create two virtualenvs to encapsulate each!
I know it doesn't answer your main question but it may help to understand what's going on.
https://virtualenv.pypa.io/en/stable/
I set up django on my mac and installed it from git into site-packages. I modified my PATH variable as
export PATH=~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/django/bin:$PATH`
but when I
echo $PATH
I see that ~/Library/Enthought/Canopy_64bit/User/bin
I haven't tested it out to see if it works but was just wondering if this is standard behavior or firstly if it was even recommended to install django in site-packages or install it separately? Either way I thought this behavior was interesting and wanted to share it just incase anyone could provide a good explanation as to what is going on?
Is by any chance ~/Library/Enthought/Canopy_64bit/User/bin a symlink pointing to ~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/django/bin ?