1, I had a new linux with python=python2.7 and python3=python3.4
2, I installed pyenv by using git
3, I installed anaconda3-4.1.1 by using pyenv and set it as global via pyenv by using pyenv global anaconda3-4.1.1
4, I created a virtualenv by using pyenv virtualenv anaconda3-4.1.1 mytestenv
5, I use import numpy to test the result. In the original anaconda3-4.1.1 env it's OK for importing numpy, but in the mytestenv env there is no numpy.
Please see the details following:
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ pyenv versions
system
* anaconda3-4.1.1 (set by /home/giza/.pyenv/version)
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ pyenv virtualenv anaconda3-4.1.1 mytestenv
Fetching package metadata .......
Solving package specifications: ..........
Package plan for installation in environment /home/giza/.pyenv/versions/anaconda3-4.1.1/envs/mytestenv:
The following NEW packages will be INSTALLED:
openssl: 1.0.2j-0
pip: 8.1.2-py35_0
python: 3.5.2-0
readline: 6.2-2
setuptools: 27.2.0-py35_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-0
zlib: 1.2.8-3
Linking packages ...
[ COMPLETE ]|##########################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate mytestenv
#
# To deactivate this environment, use:
# $ source deactivate
#
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Requirement already up-to-date: pip in /home/giza/.pyenv/versions/anaconda3- 4.1.1/envs/mytestenv/lib/python3.5/site-packages
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ pyenv activate mytestenv
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(mytestenv) giza#DESKTOP-H8KC9QC:~$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> exit()
(mytestenv) giza#DESKTOP-H8KC9QC:~$ pyenv deactivate
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$ python
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> exit()
(anaconda3-4.1.1) giza#DESKTOP-H8KC9QC:~$
Related
I messed up my conda installation and now there is no file named python in anaconda3/bin directory.
$ conda info -a
/home/username/anaconda3/bin/conda: line 2: /home/username/anaconda3/bin/python: No such file or directory
$ which python
/usr/bin/python
$ python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
When I enter the anaconda3/bin directory I can see the following files:
$ ls | grep python
ipython3.c~
ipython.c~
python3.9.c~
python3.9-config.c~
python3.c~
python3-config.c~
python.c~
I want to uninstall conda and start over but I can not use conda to install anaconda-clean with which I could uninstall conda. How can I uninstall conda completely to get rid of all inconsistencies and problems I created?
Here's how to reproduce my issue:
Create a new virtualenv:
$ virtualenv testenv --python=/usr/bin/python3.6
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in testenv/bin/python3.6
Also creating executable in testenv/bin/python
Installing setuptools, pip, wheel...done.
$ source testenv/bin/activate
(testenv) $ cd test
Install jieba and check __version__:
(testenv) test$ pip3 install jieba
Collecting jieba
Installing collected packages: jieba
Successfully installed jieba-0.39
(testenv) test$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jieba
>>> jieba.__version__
'0.39'
>>> Quit (core dumped)
Ok, version 0.39.
Install jieba3k:
(testenv) test$ pip3 install jieba3k
Collecting jieba3k
Installing collected packages: jieba3k
Successfully installed jieba3k-0.35.1
Recheck jieba __version__:
(testenv) test$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jieba
>>> jieba.__version__
'0.34'
>>> Quit (core dumped)
New version is 0.34.
Why is this happening? And how can I avoid this?
jieba and jieba3k aren't two different packages, they are two different versions of the same package with jieba being newer. When you install jieba3k it overrides package jieba with older version.
In short: forget about jieba3k, use only jieba.
Have both versions of Python (Legacy 2.7.10 and 3.6.2) installed on macOS Sierra.
Installed pip using the following steps.
Downloaded it using curl:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Installed pip it by running the installer script:
sudo python get-pip.py
Checked for any upgrades / updates for pip:
sudo pip install -U pip
Installed django 1.11:
sudo pip install django==1.11
When I run python (legacy):
python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.11
However, when trying it using python3:
python3
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
Note: I followed a different tutorial and got python3 working with django 1.11 using virtualenv - please don't suggest this as I am new to the python world and just want to use python3 / django 1.11 in a non-virtual environment - I just want have it working like the legacy python interpreter is behaving.
pip installs libraries differently for python2 and python3, so you effectively have different environments for each. If you want to install Django for python3, you'll want to install it like this:
pip3 install django==1.11
I've got statsmodels 0.5.0 and I want to upgrade to the latest version which is 0.6.0.
So I do
$ git clone git://github.com/statsmodels/statsmodels.git
$ cd statsmodels
$ pip install .
But, I get an error:
error: can't copy 'statsmodels/nonparametric/_smoothers_lowess.c': doesn't exist or not a regular file
Apparently the solution is to install Cython (which I thought was already installed, or how could statsmodels 0.5.0 ever have worked in the first place..?!?).
Anyway, so it becomes:
$ git clone git://github.com/statsmodels/statsmodels.git
$ cd statsmodels
$ pip install cython
$ pip install .
$ python
Python 2.7.3 |CUSTOM| (default, Apr 11 2012, 17:52:16)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import statsmodels
>>> statsmodels.version.full_version
'0.6.0.dev-b472807'
I have two versions of Python installed on my centOS server.
[ethan#demo ~]$ python2.6 --version
Python 2.6.6
[ehtan#demo ~]$ python --version
Python 2.7.3
The older version (2.6) is required by some essential centOS packages so I can't remove it.
When I install packages using pip, they are being installed in Python 2.6. But instead I want them to be installed to Python 2.7.
How can I change this behaviour?
For example, here is what happened when I tried installing Wand
[ethan#demo ~]$ pip install Wand
Requirement already satisfied (use --upgrade to upgrade): Wand in /usr/lib/python2.6/site-packages
Cleaning up...
[ethan#demo ~]$ python2.6
Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wand
>>> exit()
[ethan#demo ~]$ python
Python 2.7.3 (default, Oct 11 2013, 15:59:28)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wand
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wand
>>> exit()
Edit
I found this answer but it didn't work for me https://stackoverflow.com/a/4910393/3384340
You need to install pip for each python version separately.
In order to install pip for Python2.7, run
sudo easy_install-2.7 pip
Use pip-2.7 to install Wand
sudo pip-2.7 install Wand