I am a newbie to Python
and wrapping my head around some basic concepts. I come from PHP
background. Following is a definition/breakdown of the problem I am facing:
I installed anaconda
, which had a whole bunch of libraries and tools installed into my system. This is kind of my "master python environment"
Then I created and loaded a virtualenv
. In this virtualenv I loaded a few packages I wanted like pip install simplekml
, pip install ipython
Now I fired open spyder
and in the iPython console I tried to import simplekml
and it gave me an import error. I read about this issue online and it said within spyder I need to point to the python in my virtualenv (using tools > preferences > python interpreter) or I should do a pip install spyder
from my virtualenv and use that version.
I tried both. I installed spyder in my virtualenv and then in the iPython console when I import simplekml
I get the error:
ModuleNotFoundError: No module named 'simplekml'
If I go to the terminal and open iPython and type the same then it works fine. How can I have that terminal loaded to spyder?
I have been struggling with this for hours so any help you provide is greatly appreciated!
Activate the environment (e.g., conda activate [yourEnvName] ) Install spyder-kernels inside the environment (e.g., conda install spyder-kernels ) Find and copy the path for the python executable inside the environment. Finding this path can be done using from the prompt this command python -c "import sys; print(sys.
There are multiple ways of creating an environment using virtualenv, venv and conda. Conda command is preferred interface for managing installations and virtual environments with the Anaconda Python distribution.
After activating your environment, to install Spyder and its other dependencies, run pip install spyder . You may need to install a Qt binding (PyQt5) separately with pip if running under Python 2. To launch Spyder after installing, ensure your environment is activated and run the spyder3 command.
Virtualenv is only installed on DreamHost servers for Python 2. If you're working with Python 3, you must install virtualenv using pip3. pip3 is not installed on the server by default. You must first install a custom version of Python 3.
Building on what @carlos-cordoba said in his comment. If you have anaconda installed I suggest you create an anaconda environment as so:
conda create --name pyflakes spyder simplekml ipython
This will create an environment pyflakes
with spyder, simpleklm and ipython installed.
Then you just have to activate the environment with source activate pyflakes
or activate pyflakes
if you are on windows and run spyder from there.
For more information on anaconda environments, see the documentation.
EDIT: Add virtualenv example.
To user virtualenv this should work:
$ pip install virtualenv
$ cd my_project_folder
$ virtualenv my_project
$ source my_project/bin/activate
$ pip install spyder simpleklm ipython
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With