Virtualenv not installing correctly - python

I had Python 3.4 running on my Windows 8.1 system during which time virtualenv used to work correctly.
Due to some requirements not working on 3.4, I downgraded my Python version to Python 2.7.6 by cleanly uninstalling Python 3.4 from C:\Python34 and installing 2.7 in C:\Python27.
Post install of python, I installed pip and used pip install virtualenv to install virtualenv for 2.7. However, whenever I run virtualenv in my command prompt, I'm faced with the following error:
sh.exe": /c/Python34/scripts/virtualenv: No such file or directory
How do I fix this so that virtualenv uses python 2.7.6 instead of 3.4?

My first hunch is to check your PATH variable:
https://superuser.com/questions/502358/easier-way-to-change-environment-variables-in-windows-8
and see if that is still pointing to a now non-existent install. Every time I've installed python on windows, I've had to manually set that, so I wouldn't assume the uninstall would fix it automatically.

Another way is to install both python 27 and 34 at different folders. You can add 27 folder to system path, and use 34 locally. If you have eclipse with pydev or other IDE tool, just configure pythonpath variable to the corresponding version that you want to use.

Related

Multiple versions of Python in PATH

I've installed Python 3.7, and since installed python 3.8.
I've added both their folders and script folders to PATH, and made sure 3.8 is first as I'd like that to be default.
I see that the Python scripts folder has pip, pip3 and pip3.8 and the python 3.7 folder has the same (but with pip3.7 of course), so in cmd typing pip or pip3 will default to version 3.8 as I have that first in PATH.
This is great, as I can explicitly decide which pip version to run. However I don't know how to do to the same for Python. ie. run Python3.7 from cmd.
And things like Jupyter Notebooks only see a "Python 3" kernel and don't have an option for both.
How can I configure the PATH variables so I can specify which version of python3 to run?
What OS are you running? If you are running linux and used the system package panager to install python 3.8 you should be able to invoke python 3.8 by typing python3.8. Having multiple binaries named python3 in your PATH is problematic, and having python3 in your PATH point to python 3.8 instead of the system version (which is likely a lower version for your OS) will break your system's package manager. It is advisable to keep python3 in your PATH pointing to whatever the system defaults to, and use python3.8 to invoke python 3.8.
The python version that Jupyter sees will be the version from which you installed it. If you want to be able to use Jupyter with multiple python versions, create a virtual environment with your desired python version and install Jupyter in that environment. Once you activate that specific virtual env you will be sure that the jupyter command that you invoke will activate the currect python runtime.
I recommend you use pyenv a great tool for manage multiple python versions on the same system. Once installed you need to create a virtualenv, then activate the virtualenviroment and there you can install any libraries you want in a safe way.
By the way also come with an automatic installer pyenv-installer
Regards

problems creating virtualenv when installing two different versions of Python

I have installed Python 2.7, pip and virtualenv on my computer and I have created a virtual environment with this same version of Python. I installed some packages in this new virtual environment too.
Later, I decided to install Python 3.6 on the same computer to create a virtual environment that works with version 3.6. I downloaded Python 3.6 and installed it by selecting Add Python 3.6 to PATH and Install for All users and I selected the option to automatically install pip. As I had previously installed virtualenv, I have not had to reinstall it. Should I?
The problem is that, once installed, when creating a virtual environment I've got an error.
As I already had a version of Python installed I have specified that I want to use Python 3.6 in the virtual environment that I am creating:
virtualenv env2_py36 -p c: \ Python36 \ python.exe
The error already says that this usually happens when you install more than one version of Python on the same computer and warns that it is necessary to check the option Install for All Users to work (as I did) and also recommends placing the appropiate PythonXX.dll file in the Scripts folder of the virtual environment. However, I see that there is already a python36.dll file there.
Could anybody tell me what should I do to fix this problem?
On the other hand, I had previously created another virtual environment using Python 2.7. I use PyScripter to run my scripts but I don't know how to connect PyScripter to my virtual environment. It's still connected to the Python2.7's system installation.
This works for me:
virtualenv --python=python3.6 yourenvname
(3.6 is the current latest version of Python, but you can use whichever version you'd like.)

Installing Python 2.7 and 3.6 Side by Side on Mac

Python newbie here. I just bought a new Mac Book Pro (switched from Windows) and Python 2.7 is already installed on it. I want to install 3.6 side by side and choose between the two versions. I found a great tutorial located here http://joebergantine.com/articles/installing-python-2-and-python-3-alongside-each-ot/ but I'm confused on one of the command line operations. Under Python 2 Installation it says:
Install Python 2 from the latest Python.org package. This allows you to run python2 and pip. After this installation Python 2.x will be accessible at /Library/Frameworks/Python.framework/Versions/2.7/bin/.
Once the Python 2 package is installed, install virtualenv for Python
2 for the User only. When specifying the User installation, Python
packages are then accessible at ~/Library/Python/2.7/bin. Specifying
the User installation doesn't automatically add virtualenv to the
system path which we will do manually in the next step via an alias.
This is what allows Python3 and Python2 to run alongside each other:
$ pip install --user virtualenv
Do I have to be in the ~/Library/Python/2.7/bin directory when I run this command or the /Library/Frameworks/Python.framework/Versions/2.7/bin/ directory? I'm confused because I don't know where the former directory is coming from.
Why not using pip for python 2.7 and pip3 for python 3.6?
If it says pip3 is not installed you can use sudo apt-get install pip3
then you can use pip3 for python 3.6 and pip for python2.7 for installing packages for respective versions
I faced the exact error, in the exact situation about 2 years ago. The solution to your issue is pyenv. I was able to run multiple versions of python inside different folders of the same directory. It truly was a very nice solution.
Hope this helps.

virtualenv not setting virtual environment

in debian based Linux i am trying to uninstall a package installed by pip but for removing it after search it says it will only uninstall it in virtual environment after install virtualenv and upgrading it to version 15.0.3 i run command
virtualenv --no-site-packages /usr
then error occured that it is being run by interpreter and please use system python to execute the script
then i changed the python version via -p flag to python3 then it says the same msg that already using the python3 interpreter i also used simple python version still no luck
i trolled the stackoverflow & google but got no valid answer
Finally after searching and experimenting a lot I just owerwrited the new version of twisted by downloading the old one some of the files it did not deleted however all packages in the system started using newly downloaded old version of twisted!

Python 2.7.11 pip not installed

I have Python 2.7.11 installed on my machine which to my understanding should come with pip, however when I check the C:\Python27\Tools\Scripts\ directory there is no pip.exe present.
I have tried completely removing and reinstalling Python 2.7.11 without success. Running the installer pip is set to be installed, but after the install pip is nowhere to be found.
I also have Python 3.4 installed which has pip as expected. Any thoughts?
I encountered the same problem - pip not installed - with python-2.7.16, Win10, installing for 'all users'. It was resolved when I allowed the MSI installer to target the default location (C:\Python27) rather than changing it to under Program Files (x86). I've no clue why this changed anything.
python2.7.11 should install pip into c:\python27\scripts, you can take a look here
I used https://pip.pypa.io/en/stable/installing/ to make it install. Odd that an outside body has to make a tool to get pip to install. There is no mention of pip.pypa.io on the Python web site.
Although I got error messages, it did install, so check carefully.
You also may see a message suggesting that you upgrade to pip 9.0 with the command 'pip install --upgrade.' I highly recommend that.
Also, make sure you are in the directory where pip.exe is located when you run the commands. They don't tell you that, because they assume you know that, but we're not all geeks.
For people who are running into this issue, I have a Windows 10 x86 dev box that I use for exploit development, Python 2.7 was installed due to Immunity Debugger, this install did not include the new SSL package and did not include "pip".
There was no "C:\Python27\Scripts" folder which included pip. I did have a "C:\Python27\Tools\Scripts" folder which did not have pip installed.
I tired to install pip as suggested but did not work. Best way is to uninstall Python and install newest version, currently mine is 2.7.15 which came with pip as an option. This is what solved my issue, any older version of Python will need upgraded to support the SSL packages. You will receive the same errors when you try to install pip on an older version.
If you have reinstalled Python which included the SSL package and it still does not have pip, trying installing pip this way:
1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. python get-pip.py
https://pip.pypa.io/en/stable/installing/
This should work if you have a newer version of Python.
Once you have installed pip or newer version of python, go to "C:\Python27\Scripts" and you should see pip.exe.
I have installed "python-2.7.16" in my windows 10 PC. PIP is installed under "C:\Python27\Scripts". One can add the "C:\Python27\Scripts" path to environment variable and then access pip command from command prompt.
To add the path in environment variable:
Control Panel\System and Security\System --> Advanced System Settings --> Advanced --> enviroment variables --> under system variable --> Path(variable name)
Had the issue where no matter which version of python 2.7 I installed on windows 10 there was no pip.exe generated in the "Scripts" folder.
I solved it by ensuring that that MSI Installer file had Admin privileges before installing
if pip is not installed you can use easy_install.exe to install pip and other modules
you can find easy install in
python -m easy_install pip
I had the same issue:
Installed Python 27
Tried to use pip, but failed with unrecognized command error
Checked installation: no "C:\Python27\Scripts", only "C:\Python27\Tools\Scripts"
This issue happens only on some versions of Windows.
HOW TO FIX IT:
Uninstall Python 27
Reinstall Python 27, but unselect "pip" feature
Check installation: no "C:\Python27\Scripts" as expected
Start the installer again and use "Change Python"
Set "pip" and "Add Python.exe to Path" features to be installed
Check installation: "C:\Python27\Scripts" is now correctly present
So for some unknown reason, pip is not correctly installed on some versions of Windows if it is installed during default Python 27 setup. To fix this issue, pip must be installed afterwards using the "Change Python" setup.
I meet the same issue when install Python 2.7.9. The installer does not come with pip.
Solution:
Install newer python2 x86 version: https://www.python.org/downloads/release/python-2718/
Then pip is located at C:\Python27\Scripts\pip.exe
It happens on windows as you should have admin rights to install anything on disk C.
I have the same issue Scripts folder was not installed. I would sugest to instal it on disk D.

Categories