简体   繁体   中英

Installing the Zipline module in Pycharm works but it doesnt work when trying to use it

I have installed python 3.5 and 2.7 as project interpreters. Whenever I install Zipline, it says that it is installed successfully, but I cant find it in the packages nor if I type in my python file 'import zipline...'

To answer this question, it would be beneficial if you state how you installed Zipline and which Python interpreter is being used for the project. Something else that could play a role in this is whether or not you are using a virtual environment, this can be checked by clicking terminal, then if it says (venv) before the line.

Update #1

@cem When you create a project in Pycharm, it creates a virtual environment for that project. You can see if this is true by clicking "Terminal in the bottom left corner. The bottom line should look something like this: (venv) C:\\Users\\griff\\PycharmProjects\\untitled> Notice the (venv).

To find out what Python interpreter you are using for this project in Pycharm, open the terminal in Pycharm again. and type python --version this will output what Python interpreter is being used.

The way you should be installing packages in Pycharm is:

1) Click the terminal again

2) type pip install zipline

This will install the package on your venv for Pycharm and you should be able to import them.

Update #2

@cem The problem I believe, is that you are installing the library with a Python interpreter that you are not using on your Pycharm project. One way to solve this is with a virtual environment. It is a good habit for Python developers to create virtual environments for their projects, and avoid global install of libraries. So, it seems as though you are not using a virtual environment. To start a virtual environment in Pycharm follow this guide: https://www.jetbrains.com/help/pycharm-edu/creating-virtual-environment.html

Then follow the steps to install the package again as I pointed out in Update 1.

UPDATE #3

so this is not the best practices solution but at this point we just need to fix this. Open up your terminal and type python --version . take note of the version. then type either python3 pip install zipline or just pip install zipline whichever one works. After that open up Pycharm and make sure the Python interpreter you are using for that project is the same as the version that was returned when you typed python --version into terminal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM