In last project, I used python 2.7. The new one have to run in python 3.5 so I installed 3.5. I choose Python 3.5 in Setting-->Python interpreter, and I got Error : Django is not importable in this environment.
Then I tried to run
pip install django
Requirement already satisfied (use --upgrade to upgrade): django in c:\python27\lib\site-packages
Cleaning up...
It seems that something wrong with the path, and how could I make it right?
It's probably because the pip command points to python2.7 version of pip, and as django is already installed for python 2.7, you are getting the message you mentioned.
You need to install django for python3.5. To do that, either directly run pip executable inside python3.5 folder, or choose python3.5 as the interpreter from pycharm, and install django through the ui of pycharm.
Depending on how you installed python3.5, you could also run
pip3.5 install django
from the console to invoke python3.5 version of pip
Just go with pip3 suited for Python 3x envs:
pip3 install Django
Related
I installed python 3.8 in a different location than 3.7, and later uninstalled 3.7 while trying to troubleshoot issues with pip. I can't get pip to respond to install any modules now. It keeps referencing its old python 3.7 location and I don't know how to make it focus on the 3.8 installation location.
Here are the errors I'm encountering:
>pip --version
Fatal error in launcher: Unable to create process using '"c:\program files\python37\python.exe" "C:\Program Files\Python37\Scripts\pip.exe" --version': The system cannot find the file specified.
>python get-pip.py
Collecting pip
Using cached pip-20.1.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
Uninstalling pip-20.1.1:
Successfully uninstalled pip-20.1.1
Successfully installed pip-20.1.1
Now when I call pip --version is gives me the original error.
And just for more information, here are two more calls which might help troubleshoot.
>which python
/c/Users/patch/AppData/Local/Programs/Python/Python38/python
>python --version
Python 3.8.3
I just want to be able to use pip again to install modules. I'm learning some python and this pip issue is really slowing me down.
I'm open to completely uninstalling python and scrubbing the system of traces of both I just don't know what's the safest and most likely to work option.
Use
python -m pip --version
python -m pip install PACKAGE_NAME
This will use the pip that is associated with the newer python.
I suggest using the python -m pip install command over pip install because it is more clear which python version is being used.
I'd recommend scrubbing 3.7 and 3.8 from your system, then reinstalling the versions you need with pyenv (if you're using the Windows Subsystem for Linux) or pyenv-win (if not on WSL) to manage multiple Python versions. It checks the directory-specific version of Python that you've set before deciding which version's executables to use for Python, pip, etc. This solution will also work in the long term for future versions of Python you may want to install.
Future installations using pyenv or pyenv-win would involve commands like pyenv install 3.8.1. For a full list of available versions you can run pyenv install -l.
#jakub's solution will work if you want an immediate, but short-term, fix.
this question is specifically for aws cloud9. Everything looks fine prima-facie, but it's creating a lot of problems.
When i am checking python version, it's showing the correct version (without using python3)
xxxx#yyyyy.zzz:~/environment $ python --version
Python 3.6.8
When i am using which python, it's showing the correct (desired) python version
xxxx#yyyy.zzz:~/environment $ which python
alias python='python36'
/usr/bin/python36
When i am checking pip version, it's showing pip version for python 3.6, but showing a very old version of pip.
xxxx#yyyy.zzz:~/environment $ python -m pip --version
pip 9.0.3 from /usr/lib/python3.6/dist-packages (python 3.6)
When i try to upgrade pip to new version, it goes to python2.7 now (undesirable)
xxx#yyyy.zzz:~/environment $ pip install --upgrade pip
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages (20.0.2)
so, when i do a pip install of a desired package, it gets installed, but cannot use it in my program as it installs for python 2.7.
I have gone past this issue on my local windows computer a long time ago. However, this is a ec2 default environment that comes when setting up cloud9, and is a linux ubuntu dist (afaik).
Have tried to find out online, but couldn't get a simple answer. I could find answers relating to using virtualenv for these kind of issues. I am wondering if there is a simpler solution to this.
I finally resolved it by unaliasing "python" with python36.
unalias python
Then when i went to ask python version, it gave python 2.7 (as expected)
then i went for
sudo python3 -m pip install --upgrade pip
it finally worked and upgraded pip to latest.
then i could download other libraries using
python3 -m pip install <library-name>
Thanks Arun for your extensive help.
This solution may be a workaround, but it finally made it work. If anyone wants me to find the solution further, i am ready to engage.
python is an alias to point to python36. Looks like you have python 2 and python 3 installed.
python -m pip --version is returning the pip version pointing to python3 because python here refers to python3. If you try python2.7 -m pip --version it will return the pip version corresponding to python2.7
You should rather check pip --version to see the version of pip.
You could install your packages using pip3 install <package-name> or set an alias for pip to point to pip3
which pip3
Once you get the path of pip3, then you can create the alias
alias pip=`<path to pip3>
I am attempting to update pip for IDLE (Python 3.5) on mac using the terminal.
It tells me that pip is up to date in anaconda:
Daniels-MacBook-Pro-3:~ danielsellers$ pip install --upgrade pip
Requirement already up-to-date: pip in ./anaconda/lib/python3.6/site-packages
Daniels-MacBook-Pro-3:~ danielsellers$
But IDLE is recommending I update pip, which I am inclined to do because it keeps crashing while trying to install modules.
How do I update the version of pip which IDLE is running? I'm somewhat new to python, thanks in advance
If you use Anaconda you are fine, if you don't uninstall it. Systems get very confused on what you want to update/use so just pick one and use it!
I don't know commands of MAC but concept should be like this:
from terminal change directory to your Python3.5 interpreter and then go in folder called Scripts. For example:
cd C:\Python35\Scripts
Then update your pip from there like:
pip install --upgrade pip
EDIT:
In PyCharm IDLE it is in File/Settings/Project:'project_name'/Project Interpreter. In other IDLEs should be similar.
I am very new to Python installations and trying to install PIL. I have a feeling they are being installed to the wrong directory. PIP seems to have been installed fine.
Pycharm says
Try to run this command from the system terminal. Make sure that you
use the correct version of 'pip' installed for your Python interpreter
located at
'/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'.
However when checking in terminal the reply is
Jamess-MacBook-Pro:~ JamesParsons$ pip install Pillow
Requirement already satisfied (use --upgrade to upgrade): Pillow in
/Library/Python/2.7/site-packages
Its also mentions a different version of Python.
How would the best way to install PIL be as Pycharm is coming up with unresolved reference still?
On your command line:
$ which python
I'm betting that this returns:
/Library/Python/2.7/site-packages
This shows your 'basic' Python (which comes preinstalled on Mac) location. Now do:
$ which python3
If that shows this:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'
Then check for a pip3 version:
$ which pip3
If that exists and has a similar location to python3, then try this:
$ pip3 install Pillow
If that works, there is a good chance PyCharm will now pick up the correct installation.
Python is on version 2.7.3, but when i try to upgrade python through "pip" i get this:
$ pip install --upgrade python
Requirement already up-to-date: python in /usr/lib64/python2.6/lib-dynload
Cleaning up...
any suggestions?
pip installs python packages, not python itself.
Changing a system python version is a bad idea. To install an additional python version system-wide you could use your system package manager such as apt-get.
To manage personal python installations you could use pythonz.